1+ #!/usr/bin/python3
2+
13"""
24Test sbom release process
35"""
1618
1719filterwarnings ("ignore" , message = "Unverified HTTPS request" )
1820
21+ ASSET_NAME = "RKVST SaaS Software Package"
22+
1923
20- def sbom_release (arch , release , sbom_filename ): # XXX instead of filename may be URL?
24+ def sbom_release (arch , release , sbom_filename ):
2125 """
2226 Test sbom release process
2327
24- Because we use create_if_not_exists the software package asset and attachments will persist.
28+ Because we use create_if_not_exists the software package asset will persist.
2529
2630 Args:
2731 release (str): release string of form YYYYMMDD.N
32+ sbom_filename (str): name of sbom file
2833 """
2934
30- ASSET_NAME = "RKVST SAAS Software Package"
31-
3235 print (f"##[debug]Creating software package { ASSET_NAME } " )
3336
3437 asset , existed = arch .assets .create_if_not_exists (
@@ -45,25 +48,15 @@ def sbom_release(arch, release, sbom_filename): # XXX instead of filename may b
4548 "attributes" : {
4649 "arc_display_name" : ASSET_NAME ,
4750 "arc_display_type" : SBOM_PACKAGE ,
48- "arc_description" : "Software Package for RKVST SAAS" ,
49- "acme_sbom_license" : "www.gnu.org/licenses/gpl.txt" , # XXX
50- "acme_proprietary_secret" : "For your eyes only" , # XXX
51+ "arc_description" : "Software Package for RKVST SaaS" ,
5152 },
52- # the attachment should be the RKVST logo? - change accordingly XXX
53- "attachments" : [
54- {
55- "url" : (
56- "https://raw.githubusercontent.com/jitsuin-inc/archivist-python/"
57- "main/functests/test_resources/telephone.jpg" ,
58- ),
59- "content_type" : "image/jpg" ,
60- },
61- ],
6253 },
6354 confirm = True ,
6455 )
65- print ("asset" , json_dumps (asset , indent = 4 ))
66- print ("existed" , existed )
56+ print ("##[debug]Asset:\n " , json_dumps (asset , indent = 4 ))
57+ print ("##[debug]Existed:" , existed )
58+
59+ print ("" )
6760
6861 # Releasing an SBOM
6962 event = arch .events .create_from_data (
@@ -72,12 +65,12 @@ def sbom_release(arch, release, sbom_filename): # XXX instead of filename may b
7265 "operation" : "Record" ,
7366 "behaviour" : "RecordEvidence" ,
7467 "event_attributes" : {
75- "arc_description" : f"Jitsuin Inc RKVST SAAS Released { release } " ,
68+ "arc_description" : f"Jitsuin Inc RKVST SAAS Release { release } " ,
7669 "arc_display_type" : SBOM_RELEASE ,
7770 },
7871 "attachments" : [
7972 {
80- "filename" : f"{ sbom_filename } " , # XXX maybe change to URL?
73+ "filename" : f"{ sbom_filename } " ,
8174 "content_type" : "text/xml" ,
8275 "display_name" : f"RKVST { release } SBOM" ,
8376 "type" : SBOM_RELEASE ,
@@ -86,28 +79,39 @@ def sbom_release(arch, release, sbom_filename): # XXX instead of filename may b
8679 },
8780 confirm = True ,
8881 )
89- print ("release" , json_dumps (event , indent = 4 ))
90- event = arch .events .list (
91- asset_id = asset ["identity" ],
92- props = {"confirmation_status" : "CONFIRMED" },
93- attrs = {"arc_display_type" : SBOM_RELEASE },
94- )
82+ print ("##[debug]Release:\n " , json_dumps (event , indent = 4 ))
83+
84+ return (asset , event )
9585
9686
9787def main ():
9888 """
9989 main entry point
10090 """
91+
92+ rkvst_url = getenv ("RKVST_URL" )
93+
10194 auth = get_auth (
102- auth_token_filename = getenv ("TEST_AUTHTOKEN_FILENAME " ),
103- client_id = getenv ("TEST_CLIENT_ID " ),
104- client_secret_filename = getenv ("TEST_CLIENT_SECRET_FILENAME " ),
95+ auth_token_filename = getenv ("AUTHTOKEN_FILENAME " ),
96+ client_id = getenv ("CLIENT_ID " ),
97+ client_secret_filename = getenv ("CLIENT_SECRET_FILENAME " ),
10598 )
10699
107- arch = Archivist (getenv ("TEST_ARCHIVIST" ), auth , verify = False , max_time = 300 )
100+ arch = Archivist (rkvst_url , auth , verify = False , max_time = 300 )
101+
102+ asset , event = sbom_release (
103+ arch , getenv ("BUILD_BUILDNUMBER" ), getenv ("SBOM_FILEPATH" )
104+ )
105+
106+ rkvst_path = "archivist/v2"
107+
108+ asset_url = f"{ rkvst_url } /{ rkvst_path } /{ asset ['identity' ]} "
109+ event_url = f"{ rkvst_url } /{ rkvst_path } /{ event ['identity' ]} "
108110
109- # XXX: change these accordingly - filename may be a url?
110- sbom_release (arch , "YYYYMMDD.N" , "tmp/rkvst_saas_YYYYMMDD.N" )
111+ print (f"##vso[task.setvariable variable=RKVST_ASSET_URL]{ asset_url } " )
112+ print (f"##vso[task.setvariable variable=RKVST_EVENT_URL]{ event_url } " )
113+ print (f"##[debug]Asset url: { asset_url } " )
114+ print (f"##[debug]Event url: { event_url } " )
111115
112116
113117if __name__ == "__main__" :
0 commit comments