1+ include Configfile
2+
3+ # This will configure a 32-bit architecture on top of a 64-bit linux machine
4+ config-arch :
5+ sudo dpkg --add-architecture i386
6+ sudo apt-get update
7+ sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
8+
9+ # Gets the ASoC Client Tool and configures it
10+ asoc-tool : config-arch
11+ $(eval DIR := $(shell pwd) )
12+ curl -o $(HOME ) /client.zip $(APPSCAN_TOOL )
13+ mkdir $(HOME ) /client ; mkdir $(HOME ) /tool
14+ unzip -qq $(HOME ) /client.zip -d $(HOME ) /client
15+ cd $(HOME ) /client ; ls | xargs -I {} sh -c " cp -r {}/* $( HOME) /tool"
16+ rm -rf client
17+
18+ # Clone repo
19+ clone-repo :
20+ git clone $(GIT_REPO )
21+
22+ # Generates the irx file for icp-cert-manager
23+ generate-irx :
24+ cd $(TRAVIS_BUILD_DIR )
25+ $(HOME ) /tool/bin/appscan.sh prepare -oso
26+
27+ # Login to the AppScan API
28+ api-login :
29+ curl -o $(HOME ) /token.json -X POST $(CONTENT_HEADER_JSON ) $(ACCEPT_HEADER_JSON ) -d ' {"KeyId":"$(ASOC_APIKEY)", "KeySecret":"$(ASOC_SECRET)"}' $(LOGIN_URL )
30+
31+ # Uploads the irx file to the AppScan API
32+ upload-file : api-login
33+ $(eval TOKE := $(shell python getJson.py $(HOME ) /token.json "Token") )
34+ $(eval AUTH := --header 'Authorization: Bearer $(TOKE ) ')
35+ $(eval FILE := fileToUpload=@$(shell pwd) /$(notdir $(shell find $(pwd ) -maxdepth 2 -name '* .irx' -print) ) )
36+
37+ curl -o $(HOME ) /file.json -X POST --header ' Content-Type: multipart/form-data' $(ACCEPT_HEADER_JSON ) $(AUTH ) -F $(FILE ) $(UPLOAD_URL )
38+
39+ # Checks to see if Cert-Manager-Application already exists.
40+ # TODO: Error with the url, will come back to this later.
41+ get-app :
42+ $(eval TOKE := $(shell python getJson.py $(HOME ) /token.json "Token") )
43+ $(eval AUTH := --header 'Authorization: Bearer $(TOKE ) ')
44+ $(eval URL := $(GET_APP_URL ) '$(APP_NAME ) ''')
45+
46+ curl -X GET $(ACCEPT_HEADER_JSON) $(AUTH) $(URL)
47+
48+ # Assume we have an existing application, then we'll simply run the static scan
49+ run-scan :
50+ $(eval TOKE := $(shell python getJson.py $(HOME ) /token.json "Token") )
51+ $(eval AUTH := --header 'Authorization: Bearer $(TOKE ) ')
52+ $(eval FILE_ID := "$(shell python getJson.py $(HOME ) /file.json "FileId") ")
53+ $(eval APP_ID := "$(shell python getJson.py app.json "Id") ")
54+
55+ curl -X POST $(CONTENT_HEADER_JSON) $(ACCEPT_HEADER_JSON) $(AUTH) -d '{"ARSAFileId": $(FILE_ID), "ApplicationFileId": $(FILE_ID), "ScanName": "$(TRAVIS_TAG):$(TRAVIS_JOB_NUMBER):$(TRAVIS_COMMIT)", "EnableMailNotification": false, "Locale": "en-US", "AppId": $(APP_ID), "Execute": true, "Personal": false}' $(STATIC_SCAN_URL)
56+
57+ get-asset-group :
58+ $(eval TOKE := $(shell python getJson.py $(HOME ) /token.json "Token") )
59+ $(eval AUTH := --header 'Authorization: Bearer $(TOKE ) ')
60+
61+ curl -o asset.json -X GET $(ACCEPT_HEADER_JSON) $(AUTH) $(GET_ASSET_GROUP_URL)
62+
63+ # Create the application only if the application doesn't already exist.
64+ create-app : get-asset-group
65+ $(eval ASSET_GROUP_ID := "$(shell python getJson.py asset.json "Id") ")
66+ $(eval TOKE := $(shell python getJson.py $(HOME ) /token.json "Token") )
67+ $(eval AUTH := --header 'Authorization: Bearer $(TOKE ) ')
68+
69+ curl -o app.json -X POST $(CONTENT_HEADER_JSON) $(ACCEPT_HEADER_JSON) $(AUTH) -d '{"Name": $(APP_NAME), "AssetGroupId": $(ASSET_GROUP_ID), "BusinessImpact": "Unspecified"}' $(CREATE_APP_URL)
0 commit comments