mirror of
https://github.com/nsacyber/HIRS.git
synced 2024-12-22 06:17:56 +00:00
da836a0862
* Updated docker images to use python3 * Updated docker compose files. * Test Travis CI * Test Travis CI * Updated Dockerfiles. * Updated .travis.yml * Cleaned up scripts. * Cleaned up scripts. * Updated docker-compose files. * Updated amazonlinux2 image with python3. * Updated system test driver. * Updated system test driver * Cleaned up import in test driver. * Updated setup scripts to output python version
40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
# Add faulty components to the PACCOR generated JSON componentsFile.
|
|
# This will be used to create a bad platform certificate.
|
|
|
|
from __future__ import print_function
|
|
import json
|
|
import pprint
|
|
|
|
try:
|
|
badComponent = '00030003'
|
|
pcDir = '/var/hirs/pc_generation/'
|
|
paccorComponentsFile = 'componentsFile'
|
|
pBaseJsonFileOut = 'PBaseCertB.componentlist.json'
|
|
|
|
# Open the paccor components file
|
|
with open(pcDir + paccorComponentsFile, "r") as f:
|
|
|
|
# Load the info from the componentsFile
|
|
data = json.load(f)
|
|
print("The %s info:" % (paccorComponentsFile))
|
|
pp = pprint.PrettyPrinter(indent=4)
|
|
pp.pprint(data)
|
|
|
|
# Find the component to use as "FAULTY"
|
|
for component in data['COMPONENTS']:
|
|
if component['COMPONENTCLASS']['COMPONENTCLASSVALUE'] == badComponent:
|
|
print("Creating FAULTY component for: " + component['MODEL'])
|
|
component['MODEL'] += "-FAULTY"
|
|
print("New JSON value: " + component['MODEL'])
|
|
break
|
|
|
|
# Write the new JSON file to be used in creating the PBaseCertB certificate.
|
|
with open(pcDir + pBaseJsonFileOut, 'w') as outfile:
|
|
print("Writing %s%s ..." % (pcDir, pBaseJsonFileOut))
|
|
json.dump(data, outfile)
|
|
pp = pprint.PrettyPrinter(indent=4)
|
|
pp.pprint(data)
|
|
|
|
except Exception as ex:
|
|
print("=== ERROR generating PBaseCertB JSON files: %s" % (ex.message))
|