Skip to content

Commit

Permalink
Whitesource_2_Nucleus_automated.py more enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-carter committed Oct 21, 2020
1 parent 36d4e06 commit d47d151
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions whitesource/Whitesource_2_Nucleus_automated.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@
from pathlib import Path

# Enter in the root URL of your Nucleus instance.
NUCLEUS_ROOT_URL = "https://XXXXXX.nucleussec.com"
NUCLEUS_ROOT_URL = "https://XXXXXXXX.nucleussec.com"

# retrieve this API_KEY from Nucleus GUI. Must be Admin.
NUCLEUS_API_KEY = ""

#project ID from the APPSEC project in Nucleus
NUCLEUS_PROJECT_ID = ""

#retrieve this API_KEY (of the nucleus service user) in whitesource. Must have whitesource admin user.
WHITESOURCE_NUCLEUS_USER_API_KEY=""
WHITESOURCE_USER_KEY = ""

#project ID from the APPSEC project in Nucleus
NUCLEUS_PROJECT_ID=""

# Product tokens in whitesource
PRODUCTSTOKEN="""
WHITESOURCE_PRODUCT_TOKENS="""
{
"product 1":"",
"product 2":"",
"product 3":""
"Product name 1":"",
"Product name 2":""
}
"""

Expand All @@ -45,13 +45,17 @@ def post_to_nucleus(outputfile):

def get_from_whitesource(productToken):
json = {
"requestType" : "getProductVulnerabilityReport",
"userKey": WHITESOURCE_NUCLEUS_USER_API_KEY,
"productToken" : productToken,
"format" : "json"
"requestType" : "getProductVulnerabilityReport",
"userKey": WHITESOURCE_USER_API_KEY,
"productToken" : productToken,
"format" : "json"
}
# For debug
#print(json)
response=requests.post('https://app.whitesourcesoftware.com/api/v1.3', json=json)
# print(response.content)

# For debug
print(response.content)
return response.content

#need to convert JSON report from whitesource to CSV for Nucleus :/
Expand Down Expand Up @@ -106,8 +110,9 @@ def customParser(inputJsonString, outputPath):

if __name__ == "__main__":
#get all reports
jsonProductsToken=json.loads(PRODUCTSTOKEN)
#loop over all report (=whitesource project)
jsonProductsToken = json.loads(WHITESOURCE_PRODUCT_TOKENS)

#loop over all reports (=whitesource project)
for product in jsonProductsToken:
inputJsonFile = get_from_whitesource(jsonProductsToken[product])
time.sleep(5)
Expand Down

0 comments on commit d47d151

Please sign in to comment.