macaron.malware_analyzer.pypi_heuristics.sourcecode package

Submodules

macaron.malware_analyzer.pypi_heuristics.sourcecode.suspicious_setup module

This analyzer checks the suspicious pattern within setup.py.

class macaron.malware_analyzer.pypi_heuristics.sourcecode.suspicious_setup.SuspiciousSetupAnalyzer

Bases: BaseHeuristicAnalyzer

Analyzer checks heuristic.

__init__()
analyze(pypi_package_json)

Analyze suspicious packages are imported in setup.py.

Parameters:

pypi_package_json (PyPIPackageJsonAsset) – The PyPI package JSON asset object.

Returns:

The result and related information collected during the analysis.

Return type:

tuple[HeuristicResult, dict[str, JsonType]]

extract_from_ast(source_content)

Extract imports from source code using the parsed AST.

Parameters:

source_content (str) – The source code as a string.

Returns:

The set of imports.

Return type:

set[str]

Raises:

SyntaxError – If the code could not be parsed.

extract_from_lines(source_content)

Extract imports from source code using per line pattern matching.

Parameters:

source_content (str) – The source code as a string.

Returns:

The list of imports.

Return type:

set[str]