@@ -19,6 +19,7 @@ pub const DEFAULT_MAX_ROW_IDENTITY_JSONL_LINE_BYTES: usize = 64 * 1024;
1919pub const DEFAULT_MAX_ROW_IDENTITY_ROWS : usize = 10_000_000 ;
2020pub const DEFAULT_MAX_ROW_IDENTITY_TRACKED_DB_ID_BYTES : usize = 64 * 1024 * 1024 ;
2121pub const DEFAULT_MAX_AUXILIARY_ARTIFACTS : usize = 1024 ;
22+ pub const DEFAULT_MAX_AUXILIARY_ARTIFACT_BYTES : u64 = 64 * 1024 * 1024 ;
2223pub const DEFAULT_MAX_REPORT_ISSUES : usize = 1024 ;
2324pub const DEFAULT_MAX_CACHED_REPORT_BYTES : u64 = 4 * 1024 * 1024 ;
2425
@@ -1238,7 +1239,12 @@ fn verify_auxiliary_artifacts(
12381239 match resolve_auxiliary_artifact_path ( artifact, & document. base_dir , options, report) {
12391240 AuxiliaryPathResolution :: Resolved ( resolved) => {
12401241 entry. canonical_path = Some ( path_to_display ( & resolved. canonical_path ) ) ;
1241- match sha256_file ( & resolved. resolved_path ) {
1242+ match sha256_file_bounded (
1243+ & resolved. resolved_path ,
1244+ options. limits . max_auxiliary_artifact_bytes ,
1245+ "auxiliary_artifact_file_too_large" ,
1246+ "auxiliary artifact" ,
1247+ ) {
12421248 Ok ( hash) => {
12431249 entry. sha256 = Some ( hash. sha256 . clone ( ) ) ;
12441250 entry. size_bytes = Some ( hash. size_bytes ) ;
@@ -1273,17 +1279,17 @@ fn verify_auxiliary_artifacts(
12731279 }
12741280 }
12751281 Err ( err) => {
1276- mark_auxiliary_artifact_failed (
1277- & mut entry,
1278- "auxiliary_artifact_hash_failed" ,
1279- ) ;
1280- report. error (
1281- "auxiliary_artifact_hash_failed" ,
1282+ let code = err. code ( ) . unwrap_or ( "auxiliary_artifact_hash_failed" ) ;
1283+ mark_auxiliary_artifact_failed ( & mut entry, code) ;
1284+ let message = if err. code ( ) . is_some ( ) {
1285+ err. to_string ( )
1286+ } else {
12821287 format ! (
12831288 "failed to hash auxiliary artifact {:?}: {err}" ,
12841289 artifact. name
1285- ) ,
1286- ) ;
1290+ )
1291+ } ;
1292+ report. error ( code, message) ;
12871293 }
12881294 }
12891295 }
@@ -1542,6 +1548,7 @@ pub struct ResourceLimits {
15421548 pub max_row_identity_rows : usize ,
15431549 pub max_row_identity_tracked_db_id_bytes : usize ,
15441550 pub max_auxiliary_artifacts : usize ,
1551+ pub max_auxiliary_artifact_bytes : u64 ,
15451552 pub max_report_issues : usize ,
15461553 pub max_cached_report_bytes : u64 ,
15471554}
@@ -1554,6 +1561,7 @@ impl Default for ResourceLimits {
15541561 max_row_identity_rows : DEFAULT_MAX_ROW_IDENTITY_ROWS ,
15551562 max_row_identity_tracked_db_id_bytes : DEFAULT_MAX_ROW_IDENTITY_TRACKED_DB_ID_BYTES ,
15561563 max_auxiliary_artifacts : DEFAULT_MAX_AUXILIARY_ARTIFACTS ,
1564+ max_auxiliary_artifact_bytes : DEFAULT_MAX_AUXILIARY_ARTIFACT_BYTES ,
15571565 max_report_issues : DEFAULT_MAX_REPORT_ISSUES ,
15581566 max_cached_report_bytes : DEFAULT_MAX_CACHED_REPORT_BYTES ,
15591567 }
0 commit comments