Skip to content

Commit e524e8f

Browse files
Paul Hewletteccles
authored andcommitted
Minor fixes
Problem: Some incorrect documentation. Solution: Fix minor faults in documentation and update sbom release example code. Signed-off-by: User Name <user@email.com>
1 parent 682f11d commit e524e8f

File tree

6 files changed

+76
-57
lines changed

6 files changed

+76
-57
lines changed

README.rst

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
.. _readme:
23

34
Jitsuin Archivist Client
@@ -13,16 +14,23 @@ Installation
1314

1415
Use standard python pip utility:
1516

16-
.. code-block:: bash
17+
.. code:: bash
1718
1819
python3 -m pip install jitsuin-archivist
1920
21+
If your version of python3 is too old an error of this type or similar will be emitted:
22+
23+
.. note::
24+
25+
ERROR: Could not find a version that satisfies the requirement jitsuin-archivist (from versions: none)
26+
ERROR: No matching distribution found for jitsuiin-archivist
27+
2028
Example
2129
=============
2230

2331
One can then use the examples code to create assets (see examples directory):
2432

25-
.. code-block:: python
33+
.. code:: python
2634
2735
"""Create an asset given url to Archivist and user Token.
2836
@@ -138,7 +146,7 @@ or json file.
138146
Python
139147
------
140148

141-
.. code-block:: python
149+
.. code:: python
142150
143151
from logging import getLogger
144152
from pyaml_env import parse_config
@@ -182,7 +190,7 @@ Command Line
182190
183191
This functionality is also available from the command line:
184192
185-
.. code-block:: shell
193+
.. code:: shell
186194
187195
$ archivist_runner -h
188196
@@ -196,7 +204,7 @@ To invoke this command:
196204
197205
Execute:
198206
199-
.. code-block:: shell
207+
.. code:: shell
200208
201209
$ archivist_runner \
202210
-u https://app.rkvst.io \
@@ -225,7 +233,7 @@ asset or event is confirmed before returning.
225233
'true' which archivist will treat as a boolesn.
226234
227235
228-
.. code-block:: yaml
236+
.. code:: yaml
229237
230238
---
231239
# Demonstration of applying a Richness compliance policy to an asset that undergoes
@@ -294,7 +302,7 @@ by using dictionary configuration as described here: https://docs.python.org/3/l
294302
295303
A recommended minimum configuration would be:
296304
297-
.. code-block:: python
305+
.. code:: python
298306
299307
import logging
300308

docs/requirements.txt

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
#
22
# this is used for pushing to github pages
33
#
4-
# for development, the correct packages are installed in the builder image.
5-
#
6-
# Duplicate of stanza in builder/Dockerfile-builder
4+
# Duplicate of stanza in ~/requirements-dev.txt.
75
# Make changes in both places
8-
#
9-
sphinx==3.5.4
10-
sphinx-rtd-theme==0.5.2
6+
sphinx~=4.3
7+
sphinx-rtd-theme~=1.0.0
118

12-
backoff==1.10.0
13-
certifi==2020.12.5
14-
flatten-dict==0.3.0
15-
iso8601==0.1.13
16-
requests==2.22.0
17-
requests-toolbelt==0.9.1
18-
rfc3339==6.2
9+
# Duplicate of stanza in ~/requirements.txt.
10+
# Make changes in both places
11+
backoff~=1.11
12+
certifi
13+
flatten-dict~=0.3
14+
iso8601~=0.1
15+
Jinja2~=3.0
16+
pyaml-env~=1.1
17+
requests~=2.22
18+
requests-toolbelt~=0.9
19+
rfc3339~=6.2
20+
xmltodict~=0.12.0

docs/runner/events_create.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ An example when releasing a software package as an sbom:
7474
confirm: true
7575
event_attributes:
7676
arc_description: ACME Corporation Detector SAAS Released YYYYMMDD.1
77-
arc_display_type: sbom release
77+
arc_display_type: Software Package Release
7878
sbom:
7979
filename: functests/test_resources/sbom/gen1.xml
8080
content_type: text/xml
@@ -100,10 +100,9 @@ An example when releasing a software package as an sbom attachment:
100100
confirm: true
101101
event_attributes:
102102
arc_description: ACME Corporation Detector SAAS Released YYYYMMDD.1
103-
arc_display_type: sbom release
103+
arc_display_type: Software Package Release
104104
attachments:
105105
- filename: functests/test_resources/sbom/gen1.xml
106106
content_type: text/xml
107107
display_name: ACME Generation1 SBOM
108-
type: SBOM_RELEASE
109-
108+
type: Software Package Release

examples/sbom_release.py

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/python3
2+
13
"""
24
Test sbom release process
35
"""
@@ -16,19 +18,20 @@
1618

1719
filterwarnings("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

9787
def 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

113117
if __name__ == "__main__":

requirements-dev.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@ pylint~=2.6
1212
twine~=3.4
1313

1414
# documentation
15+
# the file docs/requirements.txt
16+
# must be kept in sync with this file.
1517
sphinx~=4.3
1618
sphinx-rtd-theme~=1.0.0

requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#
2+
# for the published wheel - the file docs/requirements.txt
3+
# must be kept in sync with this file.
4+
#
15
backoff~=1.11
26
certifi
37
flatten-dict~=0.3

0 commit comments

Comments
 (0)