Skip to content

Commit 6a712af

Browse files
authored
docs: make minor formatting fixes (#1098)
Signed-off-by: Ben Selwyn-Smith <benselwynsmith@googlemail.com>
1 parent 77eac50 commit 6a712af

File tree

17 files changed

+46
-46
lines changed

17 files changed

+46
-46
lines changed

src/macaron/database/db_custom_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class RFC3339DateTime(TypeDecorator): # pylint: disable=W0223
2525
https://docs.sqlalchemy.org/en/20/dialects/sqlite.html#sqlalchemy.dialects.sqlite.DATETIME
2626
"""
2727

28-
# It is stored in the database as a string
28+
# It is stored in the database as a string.
2929
impl = String
3030

3131
# To prevent Sphinx from rendering the docstrings for `cache_ok`, make this docstring private.

src/macaron/database/table_definitions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
logger: logging.Logger = logging.getLogger(__name__)
4444

45-
# TODO: Use UUIDs as primary keys rather than incremental
45+
# TODO: Use UUIDs as primary keys rather than incremental.
4646

4747
################################################################################
4848
# Analysis

src/macaron/malware_analyzer/pypi_heuristics/sourcecode/pypi_sourcecode_analyzer.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import json
1212
import logging
1313
import os
14-
import subprocess # nosec
14+
import subprocess # nosec B404
1515
import tempfile
1616

1717
import yaml
@@ -120,7 +120,7 @@ def _load_defaults(self, resources_path: str) -> tuple[str, str | None, set[str]
120120

121121
semgrep_commands: list[str] = ["semgrep", "scan", "--validate", "--oss-only", "--config", custom_rule_path]
122122
try:
123-
process = subprocess.run(semgrep_commands, check=True, capture_output=True) # nosec
123+
process = subprocess.run(semgrep_commands, check=True, capture_output=True) # nosec B603
124124
except (subprocess.CalledProcessError, subprocess.TimeoutExpired) as semgrep_error:
125125
error_msg = (
126126
f"Unable to run semgrep validation on {custom_rule_path} with arguments "
@@ -185,8 +185,8 @@ def _extract_rule_ids(self, path: str, target_files: set[str]) -> set[str]:
185185
If any Semgrep rule file could not be safely loaded, or if their format was not in the expected Semgrep
186186
format, or if there were any files in 'target_files' not found when searching in 'path'.
187187
"""
188-
# We keep a record of any file paths we coulnd't find to provide a more useful error message, rather than raising
189-
# an error on the first missing file we see.
188+
# We keep a record of any file paths we couldn't find to provide a more useful error message, rather than
189+
# raising an error on the first missing file we see.
190190
missing_files: list[str] = []
191191
target_file_paths: list[str] = []
192192
rule_ids: set[str] = set()
@@ -211,7 +211,7 @@ def _extract_rule_ids(self, path: str, target_files: set[str]) -> set[str]:
211211
logger.debug(error_msg)
212212
raise ConfigurationError(error_msg) from yaml_error
213213

214-
# should be a top-level key "rules", and then a list of rules (dictionaries) with "id" entries
214+
# Should be a top-level key "rules", and then a list of rules (dictionaries) with "id" entries.
215215
try:
216216
for semgrep_rule in semgrep_ruleset["rules"]:
217217
rule_ids.add(semgrep_rule["id"])
@@ -243,7 +243,7 @@ def analyze(self, pypi_package_json: PyPIPackageJsonAsset) -> tuple[HeuristicRes
243243
if there is no source code available.
244244
"""
245245
analysis_result: dict = {}
246-
# since we have to run them anyway, return disabled rule findings for debug information
246+
# Since we have to run them anyway, return disabled rule findings for debug information.
247247
disabled_results: dict = {}
248248
# Here, we disable 'nosemgrep' ignoring so that this is not an evasion method of our scan (i.e. malware includes
249249
# 'nosemgrep' comments to prevent our scan detecting those code lines). Read more about the 'nosemgrep' feature
@@ -266,7 +266,7 @@ def analyze(self, pypi_package_json: PyPIPackageJsonAsset) -> tuple[HeuristicRes
266266
semgrep_commands.append(f"--json-output={output_json_file.name}")
267267
logger.debug("executing: %s.", semgrep_commands)
268268
try:
269-
process = subprocess.run(semgrep_commands, check=True, capture_output=True) # nosec
269+
process = subprocess.run(semgrep_commands, check=True, capture_output=True) # nosec B603
270270
except (subprocess.CalledProcessError, subprocess.TimeoutExpired) as semgrep_error:
271271
error_msg = (
272272
f"Unable to run semgrep on {source_code_path} with arguments {semgrep_commands}: {semgrep_error}"
@@ -320,7 +320,7 @@ def analyze(self, pypi_package_json: PyPIPackageJsonAsset) -> tuple[HeuristicRes
320320
analysis_result[rule_id] = {"message": message, "detections": []}
321321
analysis_result[rule_id]["detections"].append({"file": file, "start": start, "end": end})
322322

323-
# some semgrep rules were triggered, even after removing disabled ones
323+
# Some semgrep rules were triggered, even after removing disabled ones.
324324
if analysis_result:
325325
result = HeuristicResult.FAIL
326326

src/macaron/parsers/github_workflow_model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2024 - 2024, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2024 - 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
# pylint: skip-file
44
# flake8: noqa
@@ -7,7 +7,7 @@
77
# generated by datamodel-codegen:
88
# filename: https://raw.githubusercontent.com/SchemaStore/schemastore/a1689388470d1997f2e5ebd8b430e99587b8d354/src/schemas/json/github-workflow.json
99
# timestamp: 2024-05-10T03:46:22+00:00
10-
# Some manual modifications made, noted as MODIFIED in comments below
10+
# Some manual modifications made, noted as MODIFIED in comments below.
1111

1212
from __future__ import annotations
1313

src/macaron/parsers/pomparser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# Copyright (c) 2024 - 2024, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2024 - 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 module contains the parser for POM files."""
55
import logging
6-
from xml.etree.ElementTree import Element # nosec
6+
from xml.etree.ElementTree import Element # nosec B405
77

88
import defusedxml.ElementTree
99
from defusedxml.ElementTree import fromstring

src/macaron/repo_finder/repo_finder_java.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import logging
66
import re
77
import urllib.parse
8-
from xml.etree.ElementTree import Element # nosec
8+
from xml.etree.ElementTree import Element # nosec B405
99

1010
from packageurl import PackageURL
1111

tests/artifact/test_local_artifact.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ def is_case_sensitive_filesystem() -> bool:
3131

3232
try:
3333
os.mkdir(upper)
34-
# if upper is not treated the same as lower -> case sensitive
34+
# If upper is not treated the same as lower -> case-sensitive.
3535
return True
3636
except FileExistsError:
37-
# upper is treated the same as lower -> case insensitive
37+
# Upper is treated the same as lower -> case-insensitive.
3838
return False
3939

4040

tests/macaron_testcase.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2022 - 2023, 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 module contains the MacaronTestCase class for setup/teardown of test cases."""
@@ -11,7 +11,7 @@
1111
from macaron.config.defaults import create_defaults, defaults, load_defaults
1212

1313

14-
# TODO: add fixture in the future
14+
# TODO: add fixture in the future.
1515
class MacaronTestCase(TestCase):
1616
"""The TestCase class for Macaron."""
1717

tests/malware_analyzer/pypi/test_pypi_sourcecode_analyzer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def test_nonexistent_rule_path(mock_defaults: MagicMock) -> None:
9393
@patch("macaron.malware_analyzer.pypi_heuristics.sourcecode.pypi_sourcecode_analyzer.defaults")
9494
def test_invalid_custom_rules(mock_defaults: MagicMock) -> None:
9595
"""Test for when the provided file is not a valid semgrep rule, so error,"""
96-
# use this file as an invalid semgrep rule as it is most definitely not a semgrep rule, and does exist
96+
# Use this file as an invalid semgrep rule as it is most definitely not a semgrep rule, and does exist.
9797
defaults = {
9898
"custom_semgrep_rules_path": os.path.abspath(__file__),
9999
}

tests/malware_analyzer/pypi/test_wheel_absence.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ def test_analyze_no_information(pypi_package_json: MagicMock) -> None:
2222

2323

2424
# Note: to patch a function, the way it is imported matters.
25-
# e.g. if it is imported like this: import os; os.listdir() then you patch os.listdir
26-
# if it is imported like this: from os import listdir; listdir() then you patch <module>.listdir
25+
# E.g. if it is imported like this: import os; os.listdir() then you patch os.listdir.
26+
# If it is imported like this: from os import listdir; listdir() then you patch <module>.listdir.
2727
@patch("macaron.malware_analyzer.pypi_heuristics.metadata.wheel_absence.send_head_http_raw")
2828
def test_analyze_tar_present(mock_send_head_http_raw: MagicMock, pypi_package_json: MagicMock) -> None:
2929
"""Test for when only .tar.gz is present, so failed"""
@@ -72,7 +72,7 @@ def test_analyze_tar_present(mock_send_head_http_raw: MagicMock, pypi_package_js
7272
pypi_package_json.pypi_registry.inspector_url_scheme = "https"
7373
pypi_package_json.pypi_registry.inspector_url_netloc = "inspector.pypi.io"
7474

75-
mock_send_head_http_raw.return_value = MagicMock() # assume valid URL for testing purposes
75+
mock_send_head_http_raw.return_value = MagicMock() # Assume valid URL for testing purposes.
7676

7777
expected_detail_info = {
7878
"inspector_links": {inspector_link_expected: True},
@@ -131,7 +131,7 @@ def test_analyze_whl_present(mock_send_head_http_raw: MagicMock, pypi_package_js
131131
pypi_package_json.package_json = {"info": {"name": "ttttttttest_nester"}}
132132
pypi_package_json.pypi_registry.inspector_url_scheme = "https"
133133
pypi_package_json.pypi_registry.inspector_url_netloc = "inspector.pypi.io"
134-
mock_send_head_http_raw.return_value = MagicMock() # assume valid URL for testing purposes
134+
mock_send_head_http_raw.return_value = MagicMock() # Assume valid URL for testing purposes.
135135

136136
expected_detail_info = {
137137
"inspector_links": {inspector_link_expected: True},

0 commit comments

Comments
 (0)