Skip to content

Commit

Permalink
Attachments upload with 429
Browse files Browse the repository at this point in the history
Problem:
If an attachments upload encounters a 429 then the connection is closed
resulting in a zero length file.

Solution:
Make sure that Verify is True which will enable keep-alive.
Additionally upgrade all dependencies and reformat code to latest
standard.

Signed-off-by: Paul Hewlett <[email protected]>
  • Loading branch information
eccles committed Feb 16, 2023
1 parent c9ad3c4 commit 12f08db
Show file tree
Hide file tree
Showing 11 changed files with 44 additions and 53 deletions.
6 changes: 0 additions & 6 deletions archivist_samples/door_entry/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def attachment_create(doors, name):


def create_rkvst_paris(doors):

# Unlike the others, which feature images of the whole building,
# this one is actually a close-up of the connected door terminal
return doors_creator(
Expand Down Expand Up @@ -85,7 +84,6 @@ def create_rkvst_paris(doors):


def create_cityhall(doors):

return doors_creator(
doors,
"City Hall front door",
Expand Down Expand Up @@ -148,7 +146,6 @@ def create_courts(doors):


def create_bastille(doors):

return doors_creator(
doors,
"Bastille front door",
Expand Down Expand Up @@ -182,7 +179,6 @@ def create_bastille(doors):


def create_gdn_front(doors):

return doors_creator(
doors,
"Gare du Nord apartments front door",
Expand Down Expand Up @@ -216,7 +212,6 @@ def create_gdn_front(doors):


def create_gdn_side(doors):

return doors_creator(
doors,
"Gare du Nord apartments side door",
Expand Down Expand Up @@ -577,7 +572,6 @@ def open_door(doors, doorid, cards, cardid):


def run(arch, args):

LOGGER.info("Using version %s of rkvst-archivist", about.__version__)
LOGGER.info("Fetching use case test assets namespace %s", args.namespace)

Expand Down
1 change: 0 additions & 1 deletion archivist_samples/signed_records/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ def print_history(archivist, asset_name):
# Main app loop
###############
def run(arch, args):

LOGGER.info("Using version %s of rkvst-archivist", about.__version__)
if args.namespace:
asset_name = "-".join(["signed-records", args.namespace])
Expand Down
1 change: 0 additions & 1 deletion archivist_samples/software_bill_of_materials/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@


def run(arch, args):

LOGGER.info("Using version %s of rkvst-archivist", about.__version__)
LOGGER.info("Fetching use case test assets namespace %s", args.namespace)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def create(
attachments: Optional[list] = None,
custom_attrs: Optional[dict] = None,
):

if sbom_environment is not None:
self._environment = sbom_environment
else:
Expand Down Expand Up @@ -79,7 +78,6 @@ def installation(
custom_attrs: Optional[dict] = None,
custom_asset_attrs: Optional[dict] = None,
):

if sbom_installation["environment"] is not None:
self._environment = sbom_installation["environment"]
else:
Expand Down Expand Up @@ -143,7 +141,6 @@ def decommission(
custom_attrs: Optional[dict] = None,
custom_asset_attrs: Optional[dict] = None,
):

if sbom_decomission["environment"] is not None:
self._environment = sbom_decomission["environment"]
else:
Expand Down Expand Up @@ -201,7 +198,6 @@ def upgrade(
custom_attrs: Optional[dict] = None,
custom_asset_attrs: Optional[dict] = None,
):

if sbom_upgrade["environment"] is not None:
self._environment = sbom_upgrade["environment"]
else:
Expand Down Expand Up @@ -263,7 +259,6 @@ def upgrade_plan(
attachments: Optional[list] = None,
custom_attrs: Optional[dict] = None,
):

if sbom_planned["environment"] is not None:
self._environment = sbom_planned["environment"]
else:
Expand Down Expand Up @@ -309,7 +304,6 @@ def upgrade_accepted(
attachments: Optional[list] = None,
custom_attrs: Optional[dict] = None,
):

if sbom_accepted["environment"] is not None:
self._environment = sbom_accepted["environment"]
else:
Expand Down Expand Up @@ -357,7 +351,6 @@ def rollback(
custom_attrs: Optional[dict] = None,
custom_asset_attrs: Optional[dict] = None,
):

if sbom_rollback["environment"] is not None:
self._environment = sbom_rollback["environment"]
else:
Expand Down Expand Up @@ -419,7 +412,6 @@ def rollback_plan(
attachments: Optional[list] = None,
custom_attrs: Optional[dict] = None,
):

if sbom_planned["environment"] is not None:
self._environment = sbom_planned["environment"]
else:
Expand Down Expand Up @@ -465,7 +457,6 @@ def rollback_accepted(
attachments: Optional[list] = None,
custom_attrs: Optional[dict] = None,
):

if sbom_accepted["environment"] is not None:
self._environment = sbom_accepted["environment"]
else:
Expand Down Expand Up @@ -513,7 +504,6 @@ def vuln_disclosure(
attachments: Optional[list] = None,
custom_attrs: Optional[dict] = None,
):

self._add_attachments(attachments)

props = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def create(
attachments: Optional[list] = None,
custom_attrs: Optional[dict] = None,
):

attrs = {
"arc_description": sbom_description,
"arc_display_type": "Software Package",
Expand Down Expand Up @@ -112,7 +111,6 @@ def release(
custom_attrs: Optional[dict] = None,
custom_asset_attrs: Optional[dict] = None,
):

# sbom_name: str,
# sbom_description: str,
# sbom_hash: str,
Expand Down Expand Up @@ -174,7 +172,6 @@ def release_plan(
attachments: Optional[list] = None,
custom_attrs: Optional[dict] = None,
):

props = {
"operation": "Record",
"behaviour": "RecordEvidence",
Expand Down Expand Up @@ -207,7 +204,6 @@ def release_accepted(
attachments: Optional[list] = None,
custom_attrs: Optional[dict] = None,
):

props = {
"operation": "Record",
"behaviour": "RecordEvidence",
Expand Down Expand Up @@ -242,7 +238,6 @@ def patch(
attachments: Optional[list] = None,
custom_attrs: Optional[dict] = None,
):

props = {
"operation": "Record",
"behaviour": "RecordEvidence",
Expand Down Expand Up @@ -276,7 +271,6 @@ def private_patch(
attachments: Optional[list] = None,
custom_attrs: Optional[dict] = None,
):

props = {
"operation": "Record",
"behaviour": "RecordEvidence",
Expand Down Expand Up @@ -312,7 +306,6 @@ def vuln_disclosure(
attachments: Optional[list] = None,
custom_attrs: Optional[dict],
):

props = {
"operation": "Record",
"behaviour": "RecordEvidence",
Expand Down Expand Up @@ -348,7 +341,6 @@ def vuln_update(
attachments: Optional[list] = None,
custom_attrs: Optional[dict] = None,
):

props = {
"operation": "Record",
"behaviour": "RecordEvidence",
Expand Down Expand Up @@ -386,7 +378,6 @@ def deprecation(
attachments: Optional[list] = None,
custom_attrs: Optional[dict] = None,
):

props = {
"operation": "Record",
"behaviour": "RecordEvidence",
Expand Down
42 changes: 36 additions & 6 deletions archivist_samples/synsation/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ def demo_flow(ac, asset_id, asset_type, tw, wait):
input("Press to enact White Hat Hacker")

cve_id = "CVE2020-deadbeef"
MyAsset(ac, asset_id, tw, "[email protected]",).report_vulnerability(
MyAsset(
ac,
asset_id,
tw,
"[email protected]",
).report_vulnerability(
(
f"Synsation Industries {asset_type}s are vulnerable "
f"to {cve_id}. Upgrade as soon as possible."
Expand All @@ -63,7 +68,12 @@ def demo_flow(ac, asset_id, asset_type, tw, wait):
else:
input("Press to enact OEM issue patch")

MyAsset(ac, asset_id, tw, "[email protected]",).patch_vulnerability(
MyAsset(
ac,
asset_id,
tw,
"[email protected]",
).patch_vulnerability(
f"Patch for critical vulnerability '{cve_id}' released in version 1.6",
(
"SHA256-sum for official 1.6 release: "
Expand All @@ -84,7 +94,12 @@ def demo_flow(ac, asset_id, asset_type, tw, wait):
ac, "trafficlightconformance.pdf", "application/pdf"
)

MyAsset(ac, asset_id, tw, "[email protected]",).certify_patch(
MyAsset(
ac,
asset_id,
tw,
"[email protected]",
).certify_patch(
"Safety conformance approved for version 1.6. See attached conformance report",
"DVA Conformance Report attached",
{
Expand Down Expand Up @@ -112,7 +127,12 @@ def demo_flow(ac, asset_id, asset_type, tw, wait):
else:
input("Press to enact Owner approves")

MyAsset(ac, asset_id, tw, "[email protected]",).service_required(
MyAsset(
ac,
asset_id,
tw,
"[email protected]",
).service_required(
"Version 1.6 accepted. Please install ASAP",
job_corval,
)
Expand All @@ -124,12 +144,22 @@ def demo_flow(ac, asset_id, asset_type, tw, wait):
else:
input("Press to enact Maintenance")

MyAsset(ac, asset_id, tw, "[email protected]",).service(
MyAsset(
ac,
asset_id,
tw,
"[email protected]",
).service(
f"Upgraded and restarted {asset_type} during safe downtime window",
job_corval,
)

MyAsset(ac, asset_id, tw, "[email protected]",).update_firmware(
MyAsset(
ac,
asset_id,
tw,
"[email protected]",
).update_firmware(
"Responding to vulnerability 'CVE2020-deadbeef' with patch 'v1.6'",
"1.6",
cve_corval,
Expand Down
3 changes: 1 addition & 2 deletions archivist_samples/testing/archivist_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ def common_parser(description):


def endpoint(args):

if args.verbose:
set_logger("DEBUG")
else:
Expand All @@ -115,7 +114,7 @@ def endpoint(args):
with open(args.auth_token_file, mode="r", encoding="utf-8") as tokenfile:
authtoken = tokenfile.read().strip()

arch = Archivist(args.url, authtoken, verify=False, fixtures=fixtures)
arch = Archivist(args.url, authtoken, fixtures=fixtures)

if arch is None:
LOGGER.error("Critical error. Aborting.")
Expand Down
1 change: 0 additions & 1 deletion archivist_samples/wipp/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@


def run(arch, args):

LOGGER.info("Using version %s of rkvst-archivist", about.__version__)
LOGGER.info("Fetching use case test assets namespace %s", args.namespace)

Expand Down
Loading

0 comments on commit 12f08db

Please sign in to comment.