File tree Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Original file line number Diff line number Diff line change 3
3
4
4
import glob
5
5
import json
6
+ import re
6
7
import subprocess
7
8
import tempfile
8
9
from pathlib import Path
@@ -197,13 +198,17 @@ def sbom_finder(directory):
197
198
"bomFormat" in json_data
198
199
and "specVersion" in json_data
199
200
and json_data ["bomFormat" ] == "CycloneDX"
200
- and json_data ["specVersion" ] == "1.3"
201
201
):
202
- sboms .append ({"file" : file , "type" : "cyclonedx" })
202
+ try :
203
+ spec_version = float (json_data ["specVersion" ])
204
+ except Exception :
205
+ spec_version = 0
206
+ if spec_version >= 1.3 and spec_version <= 1.5 :
207
+ sboms .append ({"file" : file , "type" : "cyclonedx" })
203
208
elif file .endswith (".xml" ):
204
209
with open (file ) as fd :
205
210
data = fd .read ()
206
- if data . find ( "cyclonedx.org/schema/bom/1.3" ) != - 1 :
211
+ if re . search ( r "cyclonedx\ .org\ /schema\ /bom\/1\.[3-5]" , data ) :
207
212
sboms .append ({"file" : file , "type" : "cyclonedx" })
208
213
elif (
209
214
data .find ("standards.iso.org/iso/19770/-2/2015/schema.xsd" )
Original file line number Diff line number Diff line change 1
1
<?xml version =" 1.0" encoding =" UTF-8" ?>
2
- <bom xmlns =" http://cyclonedx.org/schema/bom/1.3 "
2
+ <bom xmlns =" http://cyclonedx.org/schema/bom/1.4 "
3
3
serialNumber =" urn:uuid:3e671687-395b-41f5-a30f-a58921a69b79"
4
4
version =" 1" >
5
5
<components >
24
24
<version >2.11.1</version >
25
25
</component >
26
26
</components >
27
- </bom >
27
+ </bom >
Original file line number Diff line number Diff line change 1
1
{
2
2
"bomFormat" : " CycloneDX" ,
3
- "specVersion" : " 1.3 " ,
3
+ "specVersion" : " 1.5 " ,
4
4
"serialNumber" : " urn:uuid:3e671687-395b-41f5-a30f-a58921a69b79" ,
5
5
"version" : 1 ,
6
6
"components" : [
46
46
"description" : " On board firmware"
47
47
}
48
48
]
49
- }
49
+ }
You can’t perform that action at this time.
0 commit comments