Skip to content

Commit c1b1ac9

Browse files
authored
Merge branch 'master' into codegen-updates
2 parents e2db76e + db98f0c commit c1b1ac9

File tree

6 files changed

+175
-2
lines changed

6 files changed

+175
-2
lines changed

.travis.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
language: java
22
sudo: required
3-
dist: precise
3+
dist: trusty
44
jdk:
5-
- oraclejdk7
5+
- openjdk7
66
- oraclejdk8
77

88
branches:
@@ -26,9 +26,23 @@ env:
2626

2727
before_install:
2828
- sed -i.bak -e 's|https://nexus.codehaus.org/snapshots/|https://oss.sonatype.org/content/repositories/codehaus-snapshots/|g' ~/.m2/settings.xml
29+
# Work around missing crypto in openjdk7
30+
- |
31+
if [ "$TRAVIS_JDK_VERSION" == "openjdk7" ]; then
32+
sudo wget "https://bouncycastle.org/download/bcprov-ext-jdk15on-158.jar" -O "${JAVA_HOME}/jre/lib/ext/bcprov-ext-jdk15on-158.jar"
33+
sudo perl -pi.bak -e 's/^(security\.provider\.)([0-9]+)/$1.($2+1)/ge' /etc/java-7-openjdk/security/java.security
34+
echo "security.provider.1=org.bouncycastle.jce.provider.BouncyCastleProvider" | sudo tee -a /etc/java-7-openjdk/security/java.security
35+
fi
36+
37+
install:
38+
- 'if [ "${TRAVIS_TAG}" = "${TRAVIS_BRANCH}" ]; then cd appscan; make asoc-tool; cd ../; fi'
39+
40+
before_script:
41+
- 'if [ "${TRAVIS_TAG}" = "${TRAVIS_BRANCH}" ]; then chmod a+x ./appscan/ASOC.sh; fi'
2942

3043
script:
3144
- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && openssl aes-256-cbc -K $encrypted_b248e84a4806_key -iv $encrypted_b248e84a4806_iv -in config.properties.enc -out core/src/test/resources/config.properties -d || true'
45+
- 'if [ "${TRAVIS_TAG}" = "${TRAVIS_BRANCH}" ]; then ./appscan/ASOC.sh; fi'
3246
- ./gradlew install -x check
3347
- ./gradlew checkstyleMain
3448
- ./gradlew checkstyleTest

appscan/ASOC.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
cd appscan
4+
make generate-irx
5+
make upload-file
6+
make run-scan
7+
cd ../

appscan/Configfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# URLs to the CISO APIs
2+
LOGIN_URL ?= 'https://appscan.ibmcloud.com/api/V2/Account/ApiKeyLogin'
3+
UPLOAD_URL ?= 'https://appscan.ibmcloud.com/api/v2/FileUpload'
4+
GET_APP_URL ?= 'https://appscan.ibmcloud.com/api/V2/Apps?$$$$filter=Name%20eq%20'
5+
STATIC_SCAN_URL ?= 'https://appscan.ibmcloud.com/api/v2/Scans/StaticAnalyzer'
6+
CREATE_APP_URL ?= 'https://appscan.ibmcloud.com/api/V2/Apps'
7+
GET_ASSET_GROUP_URL ?= 'https://appscan.ibmcloud.com/api/V2/AssetGroups'
8+
9+
APPSCAN_CLIENT_URL ?= https://appscan.ibmcloud.com/api/SCX/StaticAnalyzer/SAClientUtil?os=
10+
OS ?= linux
11+
APPSCAN_TOOL := $(APPSCAN_CLIENT_URL)$(OS)
12+
13+
GIT_REPO ?= [email protected]:watson-developer-cloud/java-sdk.git
14+
15+
PROJECT_NAME ?= java-sdk
16+
17+
# Headers added to curl command
18+
CONTENT_HEADER_JSON := --header 'Content-Type: application/json'
19+
ACCEPT_HEADER_JSON := --header 'Accept: application/json'

appscan/Makefile

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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)

appscan/app.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"Id": "de18eee4-bb7e-4326-80dd-e0fd3f1de0bc",
3+
"AssetGroupName": "IBM Watson and Cloud Platform",
4+
"DateCreated": null,
5+
"LastUpdated": null,
6+
"LastComment": null,
7+
"RiskRating": "Unknown",
8+
"CreatedBy": null,
9+
"CriticalIssues": 0,
10+
"HighIssues": 0,
11+
"MediumIssues": 0,
12+
"LowIssues": 0,
13+
"IssuesInProgress": 0,
14+
"MaxSeverity": "Undetermined",
15+
"RR_MaxSeverity": 0,
16+
"NewIssues": 0,
17+
"OpenIssues": 0,
18+
"TotalIssues": 0,
19+
"OverallCompliance": null,
20+
"ComplianceStatuses": [],
21+
"CanBeDeleted": true,
22+
"LockedToSubscription": false,
23+
"Name": "Watson Java SDK",
24+
"AssetGroupId": null,
25+
"BusinessImpact": "Unspecified",
26+
"Url": null,
27+
"Description": null,
28+
"BusinessUnit": null,
29+
"Type": null,
30+
"Technology": null,
31+
"TestingStatus": "NotStarted",
32+
"Hosts": null,
33+
"CollateralDamagePotential": "NotDefined",
34+
"TargetDistribution": "NotDefined",
35+
"ConfidentialityRequirement": "NotDefined",
36+
"IntegrityRequirement": "NotDefined",
37+
"AvailabilityRequirement": "NotDefined",
38+
"Tester": null,
39+
"BusinessOwner": null,
40+
"DevelopmentContact": null,
41+
"PreferredOfferingType": "None"
42+
}

appscan/getJson.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import json
2+
import sys
3+
4+
def main():
5+
data = load_data()
6+
printFields(data)
7+
8+
def load_data():
9+
data = ""
10+
filename = sys.argv[1]
11+
with open(filename, "r") as read:
12+
data = json.load(read)
13+
if isinstance(data, list):
14+
data = data[0]
15+
return data
16+
17+
def printFields(data):
18+
fields = sys.argv[2:]
19+
for i in fields:
20+
print(data[i])
21+
22+
main()

0 commit comments

Comments
 (0)