File tree Expand file tree Collapse file tree
data/resource/virtual_codebase Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1591,10 +1591,13 @@ def _populate(self, scan_data):
15911591 if not resources_data :
15921592 raise Exception ('Input has no file-level scan results.' )
15931593
1594- # We collect the first Resource so we can see what attributes it has and determine
1595- # the root path from its path
1596- sample_resource_data = resources_data [0 ]
1597-
1594+ # We iterate through all the Resource(s) so that we can build attributes each resource contains
1595+
1596+ sample_resource_data = dict ()
1597+
1598+ for resource in resources_data :
1599+ sample_resource_data .update (resource )
1600+
15981601 # Collect the existing attributes of the standard Resource class
15991602 standard_res_attributes = set (f .name for f in attr .fields (Resource ))
16001603 # add these properties since they are fields but are serialized
Original file line number Diff line number Diff line change 1+ {
2+ "files" : [
3+ {
4+ "path" : " apache_to_all_notable_lic_new" ,
5+ "type" : " directory" ,
6+ "sha1" : null ,
7+ "md5" : null ,
8+ "scan_errors" : []
9+ },
10+ {
11+ "path" : " apache_to_all_notable_lic_new/a1.py" ,
12+ "type" : " file" ,
13+ "sha1" : " 535b9966048ad50a9d5eb2f167c0a3013ee5cc6f" ,
14+ "md5" : " e5658fe520bbebaf6f3d4be2e2525ab6" ,
15+ "fingerprint" : " e30cf09443e7878dfed3288886e97542" ,
16+ "scan_errors" : []
17+ },
18+ {
19+ "path" : " apache_to_all_notable_lic_new/a2.py" ,
20+ "type" : " file" ,
21+ "sha1" : " 310797523e47db8481aeb06f1634317285115091" ,
22+ "md5" : " 19efdad483f68bc9997a5c1f7ba41b26" ,
23+ "scan_errors" : []
24+ }
25+ ]
26+ }
Original file line number Diff line number Diff line change @@ -1055,6 +1055,15 @@ def test_virtual_codebase_can_process_minimal_resources_with_only_path(self):
10551055 ])
10561056 ]
10571057 assert [r .to_dict () for r in codebase .walk ()] == expected
1058+
1059+ def test_VirtualCodebase_account_fingerprint_attribute (self ):
1060+ test_file = self .get_test_loc ("resource/virtual_codebase/fingerprint_attribute.json" )
1061+ codebase = VirtualCodebase (test_file )
1062+ resources_fingerprint = [resource .fingerprint for resource in codebase .walk ()]
1063+ assert "e30cf09443e7878dfed3288886e97542" in resources_fingerprint
1064+ assert None in resources_fingerprint
1065+ assert codebase .get_resource (0 ) == codebase .root
1066+ assert resources_fingerprint .count (None ) == 2
10581067
10591068
10601069class TestCodebaseLowestCommonParent (FileBasedTesting ):
You can’t perform that action at this time.
0 commit comments