Skip to content

Commit 7a6c632

Browse files
committed
chore: move max_download_size from slsa.verifier to downloads
Signed-off-by: Carl Flottmann <[email protected]>
1 parent 3732c61 commit 7a6c632

File tree

10 files changed

+15
-15
lines changed

10 files changed

+15
-15
lines changed

docs/source/pages/tutorials/provenance.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ Build Types
204204
File Download Limit
205205
*******************
206206

207-
To prevent analyses from taking too long, Macaron imposes a configurable size limit for downloads. This includes files being downloaded for provenance verification. In cases where the limit is being reached and you wish to continue analysis regardless, you can specify a new download size in the default configuration file. This value can be found under the ``slsa.verifier`` section, listed as ``max_download_size`` with a default limit of 10 megabytes. See :ref:`How to change the default configuration <change-config>` for more details on configuring values like these.
207+
To prevent analyses from taking too long, Macaron imposes a configurable size limit for downloads. This includes files being downloaded for provenance verification. In cases where the limit is being reached and you wish to continue analysis regardless, you can specify a new download size in the default configuration file. This value can be found under the ``downloads`` section, listed as ``max_download_size`` with a default limit of 10 megabytes. See :ref:`How to change the default configuration <change-config>` for more details on configuring values like these.
208208

209209
**************************************
210210
Run ``verify-policy`` command (semver)

src/macaron/config/defaults.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ error_retries = 5
1010
[downloads]
1111
# The default timeout in seconds for downloading assets.
1212
timeout = 120
13+
# This is the acceptable maximum size (in bytes) to download an asset.
14+
max_download_size = 10000000
1315

1416
# This is the database to store Macaron's results.
1517
[database]
@@ -486,8 +488,6 @@ provenance_extensions =
486488
intoto.jsonl.gz
487489
intoto.jsonl.url
488490
intoto.jsonl.gz.url
489-
# This is the acceptable maximum size (in bytes) to download an asset.
490-
max_download_size = 10000000
491491
# This is the timeout (in seconds) to run the SLSA verifier.
492492
timeout = 120
493493
# The allowed hostnames for URL file links for provenance download

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def _get_setup_source_code(self, pypi_package_json: PyPIPackageJsonAsset) -> str
5656
with tempfile.TemporaryDirectory() as temp_dir:
5757
source_file = os.path.join(temp_dir, file_name)
5858
timeout = defaults.getint("downloads", "timeout", fallback=120)
59-
size_limit = defaults.getint("slsa.verifier", "max_download_size", fallback=10000000)
59+
size_limit = defaults.getint("downloads", "max_download_size", fallback=10000000)
6060
if not download_file_with_size_limit(sourcecode_url, {}, source_file, timeout, size_limit):
6161
return None
6262

src/macaron/provenance/provenance_finder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def find_gav_provenance(purl: PackageURL, registry: JFrogMavenRegistry) -> list[
255255
return []
256256

257257
max_valid_provenance_size = defaults.getint(
258-
"slsa.verifier",
258+
"downloads",
259259
"max_download_size",
260260
fallback=1000000,
261261
)
@@ -458,7 +458,7 @@ def download_provenances_from_ci_service(ci_info: CIInfo, download_path: str) ->
458458
for prov_asset in prov_assets:
459459
# Check the size before downloading.
460460
if prov_asset.size_in_bytes > defaults.getint(
461-
"slsa.verifier",
461+
"downloads",
462462
"max_download_size",
463463
fallback=1000000,
464464
):

src/macaron/provenance/provenance_verifier.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def verify_ci_provenance(analyze_ctx: AnalyzeContext, ci_info: CIInfo, download_
190190
return False
191191
if not Path(download_path, sub_asset["name"]).is_file():
192192
if "size" in sub_asset and sub_asset["size"] > defaults.getint(
193-
"slsa.verifier", "max_download_size", fallback=1000000
193+
"downloads", "max_download_size", fallback=1000000
194194
):
195195
logger.debug("Sub asset too large to verify: %s", sub_asset["name"])
196196
return False

src/macaron/slsa_analyzer/git_service/api_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ def download_asset(self, url: str, download_path: str) -> bool:
643643
logger.debug("Download assets from %s at %s.", url, download_path)
644644

645645
timeout = defaults.getint("downloads", "timeout", fallback=120)
646-
size_limit = defaults.getint("slsa.verifier", "max_download_size", fallback=10000000)
646+
size_limit = defaults.getint("downloads", "max_download_size", fallback=10000000)
647647
headers = {"Accept": "application/octet-stream", "Authorization": self.headers["Authorization"]}
648648

649649
return download_file_with_size_limit(url, headers, download_path, timeout, size_limit)

src/macaron/slsa_analyzer/package_registry/maven_central_registry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def get_artifact_hash(self, purl: PackageURL) -> str | None:
286286

287287
hash_algorithm = hashlib.sha256()
288288
timeout = defaults.getint("downloads", "timeout", fallback=120)
289-
size_limit = defaults.getint("slsa.verifier", "max_download_size", fallback=10000000)
289+
size_limit = defaults.getint("downloads", "max_download_size", fallback=10000000)
290290
if not stream_file_with_size_limit(artifact_url, {}, hash_algorithm.update, timeout, size_limit):
291291
return None
292292

src/macaron/slsa_analyzer/package_registry/pypi_registry.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def download_package_sourcecode(self, url: str) -> str:
257257
temp_dir = tempfile.mkdtemp(prefix=f"{package_name}_")
258258
source_file = os.path.join(temp_dir, file_name)
259259
timeout = defaults.getint("downloads", "timeout", fallback=120)
260-
size_limit = defaults.getint("slsa.verifier", "max_download_size", fallback=10000000)
260+
size_limit = defaults.getint("downloads", "max_download_size", fallback=10000000)
261261
if not download_file_with_size_limit(url, {}, source_file, timeout, size_limit):
262262
self.cleanup_sourcecode_directory(temp_dir, "Could not download the file.")
263263

@@ -295,7 +295,7 @@ def get_artifact_hash(self, artifact_url: str) -> str | None:
295295
"""
296296
hash_algorithm = hashlib.sha256()
297297
timeout = defaults.getint("downloads", "timeout", fallback=120)
298-
size_limit = defaults.getint("slsa.verifier", "max_download_size", fallback=10000000)
298+
size_limit = defaults.getint("downloads", "max_download_size", fallback=10000000)
299299
if not stream_file_with_size_limit(artifact_url, {}, hash_algorithm.update, timeout, size_limit):
300300
return None
301301

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# 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

4-
[slsa.verifier]
4+
[downloads]
55
max_download_size = 15000000
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# 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

4+
[downloads]
5+
max_download_size = 15000000
6+
47
[analysis.checks]
58
exclude =
69
include =
710
mcn_provenance_expectation_1
811
mcn_provenance_verified_1
912
mcn_trusted_builder_level_three_1
10-
11-
[slsa.verifier]
12-
max_download_size = 15000000

0 commit comments

Comments
 (0)