Skip to content
Merged
Changes from all commits
Commits
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
15 changes: 8 additions & 7 deletions src/codeql_wrapper/infrastructure/codeql_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def create_database(
language: str,
command: Optional[str] = None,
build_mode: Optional[str] = None,
repository_path: Optional[str] = None,
) -> CodeQLResult:
"""
Create a CodeQL database.
Expand All @@ -89,7 +88,6 @@ def create_database(
language: Programming language to analyze
command: Build command (required for compiled languages)
build_mode: Build mode for the database creation
repository_path: Repository path for SARIF category

Returns:
CodeQLResult with database creation information
Expand All @@ -104,10 +102,6 @@ def create_database(
language,
]

# Add SARIF category with repository path
if repository_path:
args.extend(["--sarif-category", repository_path])

# Only add build-mode if specified and not "none"
if build_mode:
args.extend(["--build-mode", build_mode])
Expand All @@ -127,6 +121,7 @@ def analyze_database(
output_format: str = "sarif-latest",
output: Optional[str] = None,
queries: Optional[List[str]] = None,
sarif_category: Optional[str] = None,
) -> CodeQLResult:
"""
Analyze a CodeQL database.
Expand All @@ -135,6 +130,8 @@ def analyze_database(
database_path: Path to the CodeQL database
output_format: Output format ('sarif-latest', 'csv', 'json')
output: Output file path
queries: List of query files or suites to run
sarif_category: SARIF category for the analysis results

Returns:
CodeQLResult with analysis information
Expand All @@ -151,6 +148,10 @@ def analyze_database(
if output:
args.extend(["--output", output])

# Add SARIF category if provided
if sarif_category:
args.extend(["--sarif-category", sarif_category])

if queries:
args.extend(queries)

Expand Down Expand Up @@ -230,7 +231,6 @@ def create_and_analyze(
language,
build_command,
build_mode=build_mode,
repository_path=repository_path,
)

if not create_result.success:
Expand All @@ -246,6 +246,7 @@ def create_and_analyze(
output_format="sarif-latest",
output=output_file,
queries=queries,
sarif_category=repository_path,
)

if not analyze_result.success:
Expand Down