Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
0f26941
Add Lint & format workflows.
Einswilli Sep 6, 2025
40e02aa
Merge branch 'AllDotPy:master' into master
Einswilli Sep 6, 2025
b9913ca
Add Code of Conduct.
Einswilli Sep 6, 2025
b6bd262
Add Contributions guide.
Einswilli Sep 6, 2025
f9dfa45
Merge branch 'master' of https://github.com/Einswilli/Valkyrie
Einswilli Sep 6, 2025
1afc3a0
Update CONTRUBUTING.md and Pyproject.toml files.
Einswilli Sep 6, 2025
30d578c
Update CONTRUBUTING.md and Pyproject.toml files.
Einswilli Sep 6, 2025
f1b4428
remove main.py file form the root dir.
Einswilli Sep 6, 2025
850e5d7
Merge branch 'AllDotPy:master' into master
Einswilli Sep 6, 2025
d6e7800
valkyrie.core: Add Scanner engine and types modules.
Einswilli Sep 6, 2025
dbaee48
feat(core): Add Scanner Configuration types and Scanner Engine.
Einswilli Sep 6, 2025
7df00ad
Merge branch 'AllDotPy:master' into master
Einswilli Sep 6, 2025
6c125cf
valkyrie.plugins: Add Security Rules Base class Secrets detector Plugin.
Einswilli Sep 7, 2025
b6c7d6c
__ # Merge branch 'master' of https://github.com/Einswilli/Valkyrie i…
Einswilli Sep 7, 2025
1ba0352
valkyrie.plugins: Add Plugin manager.
Einswilli Sep 7, 2025
d023343
valkyrie.plugins: Add Plugin manager.
Einswilli Sep 7, 2025
a2fef8b
valkyrie.plugins: Add Plugin manager.
Einswilli Sep 7, 2025
e90ba68
Merge branch 'AllDotPy:master' into master
Einswilli Sep 7, 2025
73474ef
valkyrie.plugins: Add Plugin manager.
Einswilli Sep 7, 2025
e1238c4
valkyrie.plugins: Add Plugin manager.
Einswilli Sep 7, 2025
4bfa0fa
Merge branch 'AllDotPy:master' into master
Einswilli Sep 7, 2025
e3b808a
Merge branch 'AllDotPy:master' into feat.plugins
Einswilli Sep 7, 2025
ae14c1d
Feat (plugins): Add Plugin manager
Einswilli Sep 7, 2025
f0310b4
refractor: valkyrie.plugins.secrets.
Einswilli Sep 8, 2025
ebb3a38
Merge branch 'AllDotPy:master' into master
Einswilli Sep 8, 2025
d9677d4
Merge branch 'AllDotPy:master' into feat.plugins
Einswilli Sep 8, 2025
a49198d
Merge branch 'master' into feat.plugins
Einswilli Sep 8, 2025
cf596f8
Merge branch into feat.plugins
Einswilli Sep 8, 2025
e071c5f
Merge branch 'master' into feat.plugins
Einswilli Sep 8, 2025
ce522fa
Refractor: Refractor secrets plugin to make it more cleanner.
Einswilli Sep 8, 2025
d716401
Merge branch 'AllDotPy:master' into master
Einswilli Sep 8, 2025
f405674
valkyrie,plugins: add vulnera vulnerablity scanner plugin
Einswilli Sep 11, 2025
bdc5a04
valkyrie,plugins: Fix typo in Vulnera.parser
Einswilli Sep 11, 2025
a35a54e
Merge branch 'AllDotPy:master' into master
Einswilli Sep 11, 2025
fd7fb9f
valkkyrie.plugins: Add iamx plugin foor IAM configuration Scanning
Einswilli Sep 12, 2025
46c4453
valkkyrie.plugins: Add iamx plugin foor IAM configuration Scanning
Einswilli Sep 12, 2025
a288bae
Valkyrie.core: Add Scann Result Formatters base class and SARIF Formm…
Einswilli Sep 13, 2025
a97b666
Merge branch 'AllDotPy:master' into master
Einswilli Sep 13, 2025
1e6b5b9
Merge branch 'master' of https://github.com/Einswilli/Valkyrie into f…
Einswilli Sep 13, 2025
312124c
Merge branch 'AllDotPy:master' into master
Einswilli Sep 13, 2025
1ad6ec1
Valkyrie.core: Add HTML Scann Result Formmater
Einswilli Sep 13, 2025
50d4406
Merge branch 'master' of https://github.com/Einswilli/Valkyrie into f…
Einswilli Sep 13, 2025
23ba3d4
Valkyrie.core: Add JSON Scann Result Formmater
Einswilli Sep 13, 2025
ed533d7
Merge branch 'AllDotPy:master' into master
Einswilli Sep 13, 2025
4938e53
Valkyrie.core: Add JSON Scann Result Formmater
Einswilli Sep 13, 2025
d66b07e
Valkyrie.core: New Pydantic model based Configuration for valkyrie En…
Einswilli Sep 14, 2025
90844a4
Merge branch 'AllDotPy:master' into master
Einswilli Sep 14, 2025
3f63517
Valkyrie.core: New Pydantic model based Configuration for valkyrie En…
Einswilli Sep 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ keywords = [
"pipelines", "iam", "secrets"
]
dependencies = [
"pydantic>=2.11.9",
"toml>=0.10.2",
"tomli>=2.2.1",
"yamllib>=0.0.1",
Expand Down
244 changes: 244 additions & 0 deletions valkyrie/core/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
"""
Vlakyrie Engine configuration module.
"""

from enum import Enum
from typing import (
List, Set, Optional, Dict, Any,
Type, TypeVar,
)
from pathlib import Path

from pydantic import BaseModel, Field

from valkyrie.core.types import SeverityLevel

#### GENERIC TYPES
T = TypeVar('T', bound='BaseConfigModel')

####
## LOG LEVELs
#####
class LogLevel(str, Enum):
"""Log Levels"""

DEBUG = 'debug'
INFO = 'info'
WARNING = 'warning'
ERROR = 'error'
CRITICAL = 'critical'


####
## LOG FORMAT CHOICES
#####
class LogFormat(str, Enum):
"""Log Format choices."""

PLAIN = 'plain'
JSON = 'json'


####
## LOGGING CONFIG MODEL CLASS
#####
class LoggingConfig(BaseModel):
"""Logging Configuration Model"""

enabled: bool = False
level: LogLevel = LogLevel.INFO
file: Optional[str] = None
console: bool = True
max_size: int = 10 # MB
backups: int = 5
compress: bool = True
format: LogFormat = LogFormat.PLAIN
rotate: bool = True


####
## BASE CONFIGURATION CLASS
#####
class BaseConfigModel(BaseModel):
"""Base class of all configuration models."""

class Config:
extra = 'forbid' # Undefined fields are not allowed
validate_all = True
use_enum_values = True

def to_json(self) -> Dict[str, Any]:
"""
Converts model fields into a dictionary.
"""

return self.model_dump()

def to_json_string(self) -> str:
"""
Converts model fields into a JSON string.
"""
return self.model_dump_json()

@classmethod
def from_json(cls: Type[T], json_dict: Dict[str, Any]) -> T:
"""
Loads model from a dictionary.
"""
cls.model_rebuild()
return cls.model_validate(json_dict)

@classmethod
def from_json_string(cls: Type[T], json_str: str) -> T:
"""
Loads model from a JSON string.
"""
cls.model_rebuild()
return cls.model_validate_json(json_str)


####
## SCANNER PLUGIN CONFIG MODEL CLASS
#####
class PluginConfig(BaseConfigModel):
"""Scanner Plugin Configuration"""

enabled: Optional[bool] = True
config: Dict[str,Any] = Field(
default_factory = Dict
)


####
## SCANNER CONFIG MODEL CLASS
#####
class OutputConfig(BaseConfigModel):
"""Scan Output Configuration"""

format: str = 'sarif'
"""Default output format, json, sarif, html"""

file: Optional[str] = None
"""Output file (optional)"""

verbose: Optional[bool] = False
"""Verbose logging"""

include_success: Optional[bool] = False
"""Include successful scans in output"""


####
## RULE REPOSITORY CONFIG MODEL CLASS
#####
class RuleRepositoryConfig(BaseConfigModel):
"""Remote rule repository Configuration"""

type: str = 'github'
url: str = 'AllDotPt/valkyrie-community-rules'
branch: str = 'main'
token_env: str = 'GITHUB_TOKEN'


####
## RULE CATEGORIES CONFIG MODEL CLASS
#####
class RuleCategoriesConfig(BaseConfigModel):
"""Rule Categories Configuration"""

secrets: bool = True
dependencies: bool = True
iam_config: bool = True
code_quality: bool = True
infrastructure: bool = True


####
## RULE CONFIG MODEL CLASS
#####
class RulesConfig(BaseConfigModel):
"""Remote rule repository Configuration"""

repository: Optional[RuleRepositoryConfig]
"""Remote rule repository (GitHub, GitLab, etc.)"""

local_rules_dir: str = "./rules"
"""Local rules directory"""

include_rules: List[str] = Field(
default_factory = lambda: []
)
"""Rule filters (empty = all rules enabled)"""

exclude_rules: List[str]
"""Disabled rules"""

categories: Optional[RuleCategoriesConfig] = Field(
default_factory = lambda: RuleCategoriesConfig()
)
"""Custom rule categories to enable/disable"""


####
## SCANNER CONFIG MODEL CLASS
#####
class ScanConfig(BaseConfigModel):
"""Configuration for scanner execution"""

target_path: Path
"""Target directory to scan (relative to config file)"""

include_patterns: List[str] = Field(
default_factory=lambda: ["**/*"]
)
"""File inclusion patterns (glob patterns)"""

exclude_patterns: List[str] = Field(
default_factory=lambda: [
"**/.git/**", "**/.vscode/**",
"**/node_modules/**", "**/__pycache__/**"
]
)
"""File exclusion patterns"""

max_file_size: int = 10 * 1024 * 1024 # 10MB
"""Maximum file size to scan (in bytes, default to 10MB)."""

parallel_workers: int = 4
"""Number of parallel scanning workers"""

rule_filters: Set[str] = Field(default_factory=set) # Rule IDs to include
"""Specific rules to include"""

severity_threshold: SeverityLevel = SeverityLevel.LOW
"""Minimum severity level to report"""

diff_only: bool = False
"""Scan only changed files in CI (if supported)"""

fail_on_findings: bool = True
"""Whether to fail the build on security findings"""


####
## VALKYRIE CONFIG MODEL CLASS
#####
class ValkyrieConfig(BaseConfigModel):
"""Valkyrie Configuration"""

scanner: ScanConfig
"""Scanner engine configuration."""

rules: Optional[RulesConfig]
"""Rule repositories"""

plugins: List[PluginConfig]
"""Scanner Plugins to use."""

output: OutputConfig = Field(
default_factory = lambda: OutputConfig()
)
"""Scan Result Outout format"""

ci_integration: List
"""A list of ci integration (github action, gitlab ci, etc)"""
16 changes: 15 additions & 1 deletion valkyrie/core/formatters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,23 @@
from .html import HTMLFormatter
from .json import JSONFormatter


#### GET FORMMATER
def get_formatter(name: str) -> ResultFormatter:
"""Return a Result formatter class by name"""

mapping = {
'json': JSONFormatter,
'html': HTMLFormatter,
'sarif': SARIFFormatter
}

return mapping.get(name, SARIFFormatter)

__all__ = [
ResultFormatter,
SARIFFormatter,
HTMLFormatter,
JSONFormatter
JSONFormatter,
get_formatter
]
26 changes: 0 additions & 26 deletions valkyrie/core/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,29 +251,3 @@ async def add_rule(self, rule: ScanRule) -> None:
async def update_rule(self, rule: ScanRule) -> None:
"""Update existing rule"""
pass


#### CONFIG

####
## SCANNER CONFIG MODEL CLASS
#####
@dataclass
class ScanConfig:
"""Configuration for scanner execution"""

target_path: Path
include_patterns: List[str] = field(
default_factory=lambda: ["**/*"]
)
exclude_patterns: List[str] = field(
default_factory=lambda: [
"**/.git/**", "**/.vscode/**",
"**/node_modules/**", "**/__pycache__/**"
]
)
max_file_size: int = 10 * 1024 * 1024 # 10MB
parallel_workers: int = 4
rule_filters: Set[str] = field(default_factory=set) # Rule IDs to include
severity_threshold: SeverityLevel = SeverityLevel.LOW
fail_on_findings: bool = True