@@ -236,25 +236,33 @@ scan(#{ input := InputScanResult, strategy := Strategy, tool := Tool, path := Pa
236
236
237
237
Area = setup_scan_area (InputScanner , Path , Strategy ),
238
238
239
- Mappings = maps :get (~ " detected_license_mapping" , maps :get (~ " config" , InputScanner , #{}),
240
- #{ ~ " LicenseRef-scancode-agpl-generic-additional-terms" => ~ " NOASSERTION" ,
241
- ~ " LicenseRef-scancode-free-unknown" => ~ " NOASSERTION" ,
242
- ~ " LicenseRef-scancode-generic-cla" => ~ " NOASSERTION" ,
243
- ~ " LicenseRef-scancode-generic-exception" => ~ " NOASSERTION" ,
244
- ~ " LicenseRef-scancode-generic-export-compliance" => ~ " NOASSERTION" ,
245
- ~ " LicenseRef-scancode-generic-tos" => ~ " NOASSERTION" ,
246
- ~ " LicenseRef-scancode-generic-trademark" => ~ " NOASSERTION" ,
247
- ~ " LicenseRef-scancode-gpl-generic-additional-terms" => ~ " NOASSERTION" ,
248
- ~ " LicenseRef-scancode-other-copyleft" => ~ " NOASSERTION" ,
249
- ~ " LicenseRef-scancode-other-permissive" => ~ " NOASSERTION" ,
250
- ~ " LicenseRef-scancode-patent-disclaimer" => ~ " NOASSERTION" ,
251
- ~ " LicenseRef-scancode-unknown" => ~ " NOASSERTION" ,
252
- ~ " LicenseRef-scancode-unknown-license-reference" => ~ " NOASSERTION" ,
253
- ~ " LicenseRef-scancode-unknown-spdx" => ~ " NOASSERTION" ,
254
- ~ " LicenseRef-scancode-warranty-disclaimer" => ~ " NOASSERTION" }),
239
+ Config = maps :get (~ " config" , InputScanner ,
240
+ #{ " skip_concluded" => false ,
241
+ ~ " skip_excluded" => false ,
242
+ ~ " include_files_without_findings" => true ,
243
+ ~ " detected_license_mapping" => #{
244
+ ~ " LicenseRef-scancode-agpl-generic-additional-terms" => ~ " NOASSERTION" ,
245
+ ~ " LicenseRef-scancode-free-unknown" => ~ " NOASSERTION" ,
246
+ ~ " LicenseRef-scancode-generic-cla" => ~ " NOASSERTION" ,
247
+ ~ " LicenseRef-scancode-generic-exception" => ~ " NOASSERTION" ,
248
+ ~ " LicenseRef-scancode-generic-export-compliance" => ~ " NOASSERTION" ,
249
+ ~ " LicenseRef-scancode-generic-tos" => ~ " NOASSERTION" ,
250
+ ~ " LicenseRef-scancode-generic-trademark" => ~ " NOASSERTION" ,
251
+ ~ " LicenseRef-scancode-gpl-generic-additional-terms" => ~ " NOASSERTION" ,
252
+ ~ " LicenseRef-scancode-other-copyleft" => ~ " NOASSERTION" ,
253
+ ~ " LicenseRef-scancode-other-permissive" => ~ " NOASSERTION" ,
254
+ ~ " LicenseRef-scancode-patent-disclaimer" => ~ " NOASSERTION" ,
255
+ ~ " LicenseRef-scancode-unknown" => ~ " NOASSERTION" ,
256
+ ~ " LicenseRef-scancode-unknown-license-reference" => ~ " NOASSERTION" ,
257
+ ~ " LicenseRef-scancode-unknown-spdx" => ~ " NOASSERTION" ,
258
+ ~ " LicenseRef-scancode-warranty-disclaimer" => ~ " NOASSERTION"
259
+ },
260
+ ~ " ignore_patterns" => [ ~ " **/*.ort.yml" , ~ " **/*.spdx.yml" , ~ " **/*.spdx.yaml" , ~ " **/*.spdx.json" , ~ " **/META-INF/DEPENDENCIES" , ~ " **/META-INF/DEPENDENCIES.txt" , ~ " **/META-INF/NOTICE" , ~ " **/META-INF/NOTICE.txt" ]
261
+ }),
255
262
256
263
#{ ~ " scanner" := #{ ~ " name" := ScannerName }} = NewScanResult =
257
- scan_area (Area , InputProvenance , Mappings , Tool ),
264
+ scan_area (Area , InputProvenance ,
265
+ maps :get (~ " detected_license_mapping" , Config ), Tool ),
258
266
259
267
NewScanners = #{ K => lists :usort ([ScannerName | V ]) || K := V <- Scanners },
260
268
@@ -266,11 +274,12 @@ scan(#{ input := InputScanResult, strategy := Strategy, tool := Tool, path := Pa
266
274
ok = file :write_file (
267
275
maps :get (output , Args ),
268
276
format_scan_results (
269
- Input #{ ~ " scanner" :=
270
- InputScanner #{ ~ " scan_results" := deduplicate ([NewScanResult | ScanResults ]),
271
- ~ " scanners" := NewScanners }})),
277
+ Input #{ ~ " scanner" :=
278
+ InputScanner #{ ~ " config" => Config ,
279
+ ~ " scan_results" := deduplicate ([NewScanResult | ScanResults ]),
280
+ ~ " scanners" := NewScanners }})),
272
281
273
- do_cleanup (),
282
+ % % do_cleanup()
274
283
275
284
ok .
276
285
@@ -371,7 +380,15 @@ scan_area(Area, Provenance, Mappings, "scancode") ->
371
380
372
381
% % Dig deep into the scancode result and fetch all license and copyright data from it.
373
382
get_new_results (#{ ~ " files" := Files }, Area , Mappings ) ->
374
- lists :flatmap (fun (File ) -> get_new_results (File , Area , Mappings ) end , Files );
383
+ lists :flatmap (fun (File ) -> get_new_results (File , Area , Mappings ) end , Files );
384
+ get_new_results (#{ ~ " type" := ~ " file" ,
385
+ ~ " license_detections" := []
386
+ } = F , Area , Mappings ) ->
387
+ NONEMatch = [#{ ~ " matches" => [#{~ " license_expression_spdx" => " NONE" ,
388
+ ~ " score" => 100.0 ,
389
+ ~ " start_line" => - 1 ,
390
+ ~ " end_line" => - 1 }]}],
391
+ get_new_results (F #{ ~ " license_detections" := NONEMatch }, Area , Mappings );
375
392
get_new_results (#{ ~ " type" := ~ " file" , ~ " path" := Path ,
376
393
~ " license_detections" := Licenses ,
377
394
~ " copyrights" := Copyrights
@@ -455,7 +472,18 @@ batch(Filter, Batch, [H | T], Acc, Curr, Cnt) ->
455
472
end .
456
473
457
474
format_scan_results (ScanResult ) ->
458
- json :format (sort_arrays (ScanResult , fun (Key ) -> Key =/= ~ " scan_results" end )).
475
+ json :format (sort_arrays (ScanResult ,
476
+ fun (Key ) ->
477
+ if Key =:= ~ " scan_results" -> false ;
478
+ Key =:= ~ " licenses" ; Key =:= ~ " copyrights" ->
479
+ fun (#{ ~ " location" := #{ ~ " path" := AP }} = A , #{ ~ " location" := #{ ~ " path" := BP }} = B ) ->
480
+ if AP =:= BP -> A =< B ;
481
+ true -> AP =< BP
482
+ end
483
+ end ;
484
+ true -> true
485
+ end
486
+ end )).
459
487
460
488
sort_arrays (JSon ) ->
461
489
sort_arrays (JSon , fun (_ ) -> true end ).
@@ -468,7 +496,9 @@ sort_arrays(List, KeyFun, Sort) when is_list(List) ->
468
496
if Sort ->
469
497
lists :sort (UnsortedArray );
470
498
not Sort ->
471
- UnsortedArray
499
+ UnsortedArray ;
500
+ is_function (Sort ) ->
501
+ lists :sort (Sort , UnsortedArray )
472
502
end ;
473
503
sort_arrays (Value , _KeyFun , _Sort ) -> Value .
474
504
0 commit comments