Skip to content

Commit ae596f5

Browse files
committed
refactor: refactoring existing source code analysis functionality
1 parent 85d9f01 commit ae596f5

File tree

10 files changed

+421
-263
lines changed

10 files changed

+421
-263
lines changed

src/macaron/__main__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2022 - 2024, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2022 - 2025, Oracle and/or its affiliates. All rights reserved.
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
33

44
"""This is the main entrypoint to run Macaron."""
@@ -179,7 +179,7 @@ def analyze_slsa_levels_single(analyzer_single_args: argparse.Namespace) -> None
179179
analyzer_single_args.sbom_path,
180180
deps_depth,
181181
provenance_payload=prov_payload,
182-
validate_malware_switch=analyzer_single_args.validate_malware_switch,
182+
analyze_source=analyzer_single_args.analyze_source,
183183
)
184184
sys.exit(status_code)
185185

@@ -486,10 +486,13 @@ def main(argv: list[str] | None = None) -> None:
486486
)
487487

488488
single_analyze_parser.add_argument(
489-
"--validate-malware-switch",
489+
"--analyze-source",
490490
required=False,
491491
action="store_true",
492-
help=("Enable malware validation."),
492+
help=(
493+
"EXPERIMENTAL. For improved malware detection, analyze the source code of the"
494+
+ " (PyPI) package using a textual scan and dataflow analysis."
495+
),
493496
)
494497

495498
# Dump the default values.

src/macaron/config/defaults.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,3 +594,7 @@ major_threshold = 20
594594
epoch_threshold = 3
595595
# The number of days +/- the day of publish the calendar versioning day may be.
596596
day_publish_error = 4
597+
598+
# yaml configuration file containing suspicious patterns. Can be full path or relative to
599+
# folder where macaron is installed
600+
suspicious_patterns_file = src/macaron/malware_analyzer/pypi_heuristics/sourcecode/suspicious_patterns.yaml

src/macaron/malware_analyzer/pypi_heuristics/heuristics.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ class Heuristics(str, Enum):
3737
#: Indicates that the package has an unusually large version number for a single release.
3838
ANOMALOUS_VERSION = "anomalous_version"
3939

40+
#: Indicates that the package source code contains suspicious code patterns.
41+
SUSPICIOUS_PATTERNS = "suspicious_patterns"
42+
4043

4144
class HeuristicResult(str, Enum):
4245
"""Result type indicating the outcome of a heuristic."""

0 commit comments

Comments
 (0)