Skip to content

Commit

Permalink
Merge pull request #60 from MackenzieBingham/main
Browse files Browse the repository at this point in the history
Fixing The Uploads API Examples
  • Loading branch information
DaleBinghamSoteriaSoft authored Jun 8, 2024
2 parents 8fd1ab3 + d2d5e9b commit 8a321d9
Show file tree
Hide file tree
Showing 20 changed files with 81 additions and 20 deletions.
2 changes: 1 addition & 1 deletion python/checklist/uploadAllChecklists.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Upload a folder of SCAP XCCDF XML data, CKL data, or Audit Compliance .nessus data
# ex: python3 uploadAllChecklists.py http://192.168.13.111:8080 companyinfra openrmfprosvc hvs.xxxxxxxxxxxxxxxxx ../data/checklists/
# ex: python3 uploadAllChecklists.py http://192.168.13.111:8080 companyinfra openrmfprosvc hvs.xxxxxxxxxxxxxxxxx ../../data/checklists/

import sys
import requests
Expand Down
2 changes: 1 addition & 1 deletion python/checklist/uploadSystemPackageChecklistScan.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Upload SCAP XCCDF XML data, CKL data, or Audit Compliance .nessus data
# ex: python3 uploadSystemPackageChecklistScan.py http://192.168.13.111:8080 companyinfra openrmfprosvc hvs.xxxxxxxxxxxxxxxxx ../data/nessus-scans/ MachinaBio_System_Scan_Post-Patch-Dec_2020.nessus
# ex: python3 uploadSystemPackageChecklistScan.py http://192.168.13.111:8080 companyinfra openrmfprosvc hvs.xxxxxxxxxxxxxxxxx ../../data/checklists/ MachinaBio_System_Scan_Post-Patch-Dec_2020.nessus

import sys
import requests
Expand Down
2 changes: 1 addition & 1 deletion python/checklist/uploadTeamSubpackageChecklistScan.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Upload SCAP XCCDF XML data, CKL data, or Audit Compliance .nessus data
# ex: python3 uploadTeamSubpackageChecklistScan.py http://192.168.13.111:8080 companyinfra networkteam openrmfprosvc hvs.xxxxxxxxxxxxxxxx ../data/scap-scans/ DEGTHAT_SCC-5.0.1_2019-04-19_170849_XCCDF-Results_Microsoft_Outlook_2016-001.003.xml
# ex: python3 uploadTeamSubpackageChecklistScan.py http://192.168.13.111:8080 companyinfra networkteam openrmfprosvc hvs.xxxxxxxxxxxxxxxx ../../data/scap-scans/ DEGTHAT_SCC-5.0.1_2019-04-19_170849_XCCDF-Results_Microsoft_Outlook_2016-001.003.xml

import sys
import requests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Upload a Compliance Statement List file
# ex: python3 uploadSystemPackageComplianceStatementList.py http://192.168.13.111:8080 companyinfra openrmfprosvc hvs.xxxxxxxxxxxxxxxx ../data/ComplianceData/ compliancetest-ComplianceStatements.xlsx
# ex: python3 uploadSystemPackageComplianceStatementList.py http://192.168.13.111:8080 companyinfra openrmfprosvc hvs.xxxxxxxxxxxxxxxx ../../data/ComplianceData/ compliancetest-ComplianceStatements.xlsx

import sys
import requests
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Upload a piece of Evidence to the Checklist Vulnerability category of evidence documents, passing in the checklist Id and Vulnerability Id
# The checklist Internal Id String can be found by listing checklists with the listSystemPackageChecklists script
# ex: python3 uploadSystemPackageChecklistVulnerabilityEvidence.py http://192.168.13.111:8080 companyinfra openrmfprosvc hvs.xxxxxxxxxxxxxxxx 64a41265a61876599144c3bb V-220575 "my-title" "my-description-text" ../data/evidence/ a-frame-glass-front-cabin.jpg
# ex: python3 uploadSystemPackageChecklistVulnerabilityEvidence.py http://192.168.13.111:8080 companyinfra openrmfprosvc hvs.xxxxxxxxxxxxxxxx 64a41265a61876599144c3bb V-220575 "my-title" "my-description-text" ../../data/evidence/ a-frame-glass-front-cabin.jpg

import sys
import requests
Expand Down
2 changes: 1 addition & 1 deletion python/evidence/uploadSystemPackageComplianceEvidence.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Upload a piece of Evidence to the Compliance Statement category of evidence documents, passing in the CCI-xxxxxx Id referenced
# ex: python3 uploadSystemPackageComplianceEvidence.py http://192.168.13.111:8080 companyinfra openrmfprosvc hvs.xxxxxxxxxxxxxxxx CCI-000015 "my-title" "my-description-text" ../data/evidence/ Disaster-Recovery-Plan.pdf
# ex: python3 uploadSystemPackageComplianceEvidence.py http://192.168.13.111:8080 companyinfra openrmfprosvc hvs.xxxxxxxxxxxxxxxx CCI-000015 "my-title" "my-description-text" ../../data/evidence/ Disaster-Recovery-Plan.pdf

import sys
import requests
Expand Down
2 changes: 1 addition & 1 deletion python/evidence/uploadSystemPackageGeneralEvidence.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Upload a piece of Evidence to the General category of evidence documents
# ex: python3 uploadSystemPackageGeneralEvidence.py http://192.168.13.111:8080 companyinfra openrmfprosvc hvs.xxxxxxxxxxxxxxxx ../data/evidence/ Disaster-Recovery-Plan.pdf
# ex: python3 uploadSystemPackageGeneralEvidence.py http://192.168.13.111:8080 companyinfra openrmfprosvc hvs.xxxxxxxxxxxxxxxx ../../data/evidence/ Disaster-Recovery-Plan.pdf

import sys
import requests
Expand Down
2 changes: 1 addition & 1 deletion python/evidence/uploadSystemPackagePOAMEvidence.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Upload a piece of Evidence to the POAM category of evidence documents, passing in the # POAM Item Id generated in the listing
# ex: python3 uploadSystemPackagePOAMEvidence.py http://192.168.13.111:8080 companyinfra openrmfprosvc hvs.xxxxxxxxxxxxxxxx 125 "my-title" "my-description-text" ../data/evidence/ Disaster-Recovery-Plan.pdf
# ex: python3 uploadSystemPackagePOAMEvidence.py http://192.168.13.111:8080 companyinfra openrmfprosvc hvs.xxxxxxxxxxxxxxxx 125 "my-title" "my-description-text" ../../data/evidence/ Disaster-Recovery-Plan.pdf

import sys
import requests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
user_data = str(user_data).replace("False", 'false')
user_json_object = json.loads(user_data)
#print(json.dumps(user_json_object, indent=1))

userTable.add_row([user_json_object["id"],user_json_object["username"],user_json_object["firstName"], user_json_object["lastName"],user_json_object["email"]])
userTable.add_row([user_json_object["id"],user_json_object["username"],user_json_object["firstName"],user_json_object["lastName"],user_json_object["email"]])
# print the table out
print(userTable)
62 changes: 62 additions & 0 deletions python/keycloak/python-keycloak-lib/getUserByRolesAndGroups.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Get a user record for the realm and username parameters passed in, if it is there
# fix formatting and return JSON
# to run: python3 getUserByRolesAndGroups.py https://keycloak.mycompany.com/auth/ openrmfpro python-keycloak 8675867tyjhgjghuy5675&JKHLKJH user.name

import sys
import json
from prettytable import PrettyTable, ALL
from keycloak import KeycloakAdmin
from keycloak import KeycloakOpenIDConnection

keycloak_connection = KeycloakOpenIDConnection(
server_url=sys.argv[1],
realm_name=sys.argv[2],
client_id=sys.argv[3],
client_secret_key=sys.argv[4],
verify=True)

keycloak_admin = KeycloakAdmin(connection=keycloak_connection)

# set the headers
userRolesGroupsTable = PrettyTable(["Roles", "Groups"], align='l', max_width=40)
userRolesGroupsTable.hrules=ALL

user_id_keycloak = keycloak_admin.get_user_id(sys.argv[5])
if user_id_keycloak is None:
print("User Id was not found for that Username\n")
else:
user_data = keycloak_admin.get_user(user_id_keycloak)
user_data = str(user_data).replace("'", '"')
user_data = str(user_data).replace("True", 'true')
user_data = str(user_data).replace("False", 'false')
user_json_object = json.loads(user_data)
#print(json.dumps(user_json_object, indent=1))

usernameRoles = []
usernameGroups = []

# to get a list of user roles
userRoles = keycloak_admin.get_all_roles_of_user(user_id= ["id"])
userRoles = str(userRoles).replace("'", '"')
userRoles = str(userRoles).replace("True", 'true')
userRoles = str(userRoles).replace("False", 'false')
userRoles_json_object = json.loads(userRoles)

# for each role in the embedded listing, put into an array
for roleName in userRoles_json_object["realmMappings"]:
if (roleName["name"] not in "default-roles-openrmfpro"):
usernameRoles.append(roleName["name"])

# get all the groups
userGroups = keycloak_admin.get_user_groups(user_id=["id"])
userGroups = str(userGroups).replace("'", '"')
userGroups = str(userGroups).replace("True", 'true')
userGroups = str(userGroups).replace("False", 'false')
userGroups_json_object = json.loads(userGroups)
# get all the group names and put into an array
for groupName in userGroups_json_object:
usernameGroups.append(groupName["name"])

userRolesGroupsTable.add_row([user_json_object["id"],user_json_object["username"],user_json_object["firstName"],user_json_object["lastName"],user_json_object["email"]])
# print the table out
print(userRolesGroupsTable)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Upload Technology Vulnerability scan results *.json file
# ex: python3 uploadSystemPackageTechVulnerabilityScan.py http://192.168.13.111:8080 companyinfra openrmfprosvc hvs.xxxxxxxxxxxxxxxx 20 ../data/vulnerability-scans/containerscan.json
# ex: python3 uploadSystemPackageTechVulnerabilityScan.py http://192.168.13.111:8080 companyinfra openrmfprosvc hvs.xxxxxxxxxxxxxxxx 20 ../../data/vulnerability-scans/container/containerscan.json

import sys
import requests
Expand Down
2 changes: 1 addition & 1 deletion python/patch/uploadSystemPackageHardwareList.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Upload a Hardware List file
# ex: python3 uploadSystemPackageHardwareList.py http://192.168.13.111:8080 companyinfra openrmfprosvc hvs.xxxxxxxxxxxxxxxx ../data/Hardware/ degthatnetwork-hardwareassetlist.xlsx
# ex: python3 uploadSystemPackageHardwareList.py http://192.168.13.111:8080 companyinfra openrmfprosvc hvs.xxxxxxxxxxxxxxxx ../../data/Hardware/ degthatnetwork-hardwareassetlist.xlsx

import sys
import requests
Expand Down
2 changes: 1 addition & 1 deletion python/patch/uploadSystemPackagePPSMList.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Upload a ports/protocols/services list file
# ex: python3 uploadSystemPackagePPSMList.py http://192.168.13.111:8080 companyinfra openrmfprosvc hvs.xxxxxxxxxxxxxxxx ../data/PPSM/ degthatnetwork-ppsm.xlsx
# ex: python3 uploadSystemPackagePPSMList.py http://192.168.13.111:8080 companyinfra openrmfprosvc hvs.xxxxxxxxxxxxxxxx ../../data/PPSM/ degthatnetwork-ppsm.xlsx

import sys
import requests
Expand Down
2 changes: 1 addition & 1 deletion python/patch/uploadSystemPackagePatchScan.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Upload Nessus patch scan results *.nessus file, .xml Nexpose or .JSON universal patch format file
# ex: python3 uploadSystemPackagePatchScan.py http://192.168.13.111:8080 companyinfra openrmfprosvc hvs.xxxxxxxxxxxxxxxx ../data/patch-vulnerability-scans/ DEGTHAT-2023-May.nessus
# ex: python3 uploadSystemPackagePatchScan.py http://192.168.13.111:8080 companyinfra openrmfprosvc hvs.xxxxxxxxxxxxxxxx ../../data/patch-vulnerability-scans/ DEGTHAT-2023-May.nessus

import sys
import json
Expand Down
2 changes: 1 addition & 1 deletion python/patch/uploadSystemPackageSoftwareList.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Upload a Software list file
# ex: python3 uploadSystemPackageSoftwareList.py http://192.168.13.111:8080 companyinfra openrmfprosvc hvs.xxxxxxxxxxxxxxxx ../data/Software/ degthatnetwork-softwareassetlist.xlsx
# ex: python3 uploadSystemPackageSoftwareList.py http://192.168.13.111:8080 companyinfra openrmfprosvc hvs.xxxxxxxxxxxxxxxx ../../data/Software/ degthatnetwork-softwareassetlist.xlsx

import sys
import requests
Expand Down
2 changes: 1 addition & 1 deletion python/patch/uploadTeamSubpackagePatchScan.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Upload Nessus patch scan results *.nessus file
# ex: python3 uploadTeamSubpackagePatchScan.py http://192.168.13.111:8080 companyinfra network team openrmfprosvc hvs.xxxxxxxxxxxxxxxx ../data/patch-vulnerability-scans/ DEGTHAT-2023-May.nessus
# ex: python3 uploadTeamSubpackagePatchScan.py http://192.168.13.111:8080 companyinfra network team openrmfprosvc hvs.xxxxxxxxxxxxxxxx ../../data/patch-vulnerability-scans/ DEGTHAT-2023-May.nessus

import sys
import requests
Expand Down
2 changes: 1 addition & 1 deletion python/poam/uploadSystemPackageMitigationStatementList.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Upload a Mitigation Statement List file
# ex: python3 uploadSystemPackageMitigationStatementList.py http://192.168.13.111:8080 companyinfra openrmfprosvc hvs.xxxxxxxxxxxxxxxx ../data/Mitigations/ degthatnetwork-mitigationlist.xlsx
# ex: python3 uploadSystemPackageMitigationStatementList.py http://192.168.13.111:8080 companyinfra openrmfprosvc hvs.xxxxxxxxxxxxxxxx ../../data/Mitigations/ degthatnetwork-mitigationlist.xlsx

import sys
import requests
Expand Down
2 changes: 1 addition & 1 deletion python/systempackage/downloadCyberReadinessXLSX.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

resp = requests.get(url, headers=headers)
filename = sys.argv[2] + "-CyberReadiness.xlsx"
filepath = './download/'
filepath = '../download/'
file_path = os.path.join(filepath, filename)
r = requests.get(url, headers=headers, stream=True)
if r.ok:
Expand Down
2 changes: 1 addition & 1 deletion python/template/uploadOrganizationTemplateChecklist.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Upload checklist for Organization Template
# ex: python3 uploadOrganizationTemplateChecklist.py http://192.168.13.111:8080 openrmfprosvc hvs.xxxxxxxxxxxxxxxx "My title" "My description" ../data/ checklist.ckl
# ex: python3 uploadOrganizationTemplateChecklist.py http://192.168.13.111:8080 openrmfprosvc hvs.xxxxxxxxxxxxxxxx "My title" "My description" ../../data/ checklist.ckl

import sys
import requests
Expand Down
2 changes: 1 addition & 1 deletion python/template/uploadPackageTemplateChecklist.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Upload checklist for System Package Template
# ex: python3 uploadPackageTemplateChecklist.py http://192.168.13.111:8080 package-key openrmfprosvc hvs.xxxxxxxxxxxxxxxx "My title" "My description" ../data/ checklist.ckl
# ex: python3 uploadPackageTemplateChecklist.py http://192.168.13.111:8080 package-key openrmfprosvc hvs.xxxxxxxxxxxxxxxx "My title" "My description" ../../data/ checklist.ckl

import sys
import requests
Expand Down

0 comments on commit 8a321d9

Please sign in to comment.