Skip to content

Commit 2f3878d

Browse files
authored
Security analysis and Makefile (#156)
* - Add dependency-check as dependency - Add Makefile for common commands (lint, security check, build, release, publish, etc) - Add CI step (see notes) * - Test GitHub CI security check * - Fail on severe CVSs - Fix CI security scan * - Fix security report upload on CI
1 parent 9c0db66 commit 2f3878d

File tree

3 files changed

+80
-2
lines changed

3 files changed

+80
-2
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ name: CI
22

33
on:
44
push:
5-
branches: [master]
5+
branches: [ master ]
66
pull_request: ~
77

88
jobs:
99
build:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
javaversion: ["8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18"]
13+
javaversion: [ "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18" ]
1414
steps:
1515
- uses: actions/checkout@v3
1616
- name: Set up Java ${{ matrix.javaversion }}
@@ -31,3 +31,14 @@ jobs:
3131
fail_on_error: true
3232
checkstyle_config: easypost_java_style.xml
3333
tool_name: "style_enforcer"
34+
security:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v3
38+
- name: Run security check
39+
run: make scan
40+
- name: Upload Test results
41+
uses: actions/upload-artifact@master
42+
with:
43+
name: DependencyCheck report
44+
path: ${{github.workspace}}/target/dependency-check-report.html

Makefile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
## help - Display help about make targets for this Makefile
2+
help:
3+
@cat Makefile | grep '^## ' --color=never | cut -c4- | sed -e "`printf 's/ - /\t- /;'`" | column -s "`printf '\t'`" -t
4+
5+
## build-release - Build the project for release
6+
# @parameters:
7+
# pass= - The GPG password to sign the release
8+
build-release:
9+
mvn clean install -Dgpg.passphrase=${pass}
10+
11+
## build-dev - Build the project for development
12+
build-dev:
13+
mvn clean install -DskipTests=true -Dgpg.skip=true -Dcheckstyle.skip=true -Dcheckstyle.skip=true -Ddependency-check.skip=true -Djavadoc.skip=true
14+
15+
## publish - Publish a release of the project
16+
# @parameters:
17+
# pass= - The GPG password to sign the release
18+
publish:
19+
mvn clean deploy -Dgpg.passphrase=${pass}
20+
21+
## test - Test the project
22+
test:
23+
mvn --batch-mode install -Dgpg.skip=true -Dcheckstyle.skip=true -Dcheckstyle.skip=true -Ddependency-check.skip=true -Djavadoc.skip=true
24+
25+
## clean - Clean the project
26+
clean:
27+
mvn clean
28+
29+
# install-checkstyle - Install CheckStyle
30+
install-checkstyle:
31+
wget -O checkstyle.jar -q https://github.com/checkstyle/checkstyle/releases/download/checkstyle-10.3.1/checkstyle-10.3.1-all.jar
32+
33+
## lint - Check if project follows CheckStyle rules (must run install-checkstyle first)
34+
lint:
35+
java -jar checkstyle.jar src -c easypost_java_style.xml -d
36+
37+
## scan - Scan the project for serious security issues
38+
scan:
39+
mvn verify -DskipTests=true -Dgpg.skip=true -Dcheckstyle.skip=true -Djavadoc.skip=true -Ddependency-check.failBuildOnCVSS=7 -Ddependency-check.junitFailOnCVSS=7
40+
41+
## scan-strict - Scan the project for any security issues (strict mode)
42+
scan-strict:
43+
mvn verify -DskipTests=true -Dgpg.skip=true -Dcheckstyle.skip=true -Djavadoc.skip=true -Ddependency-check.failBuildOnCVSS=0 -Ddependency-check.junitFailOnCVSS=0
44+
45+
.PHONY: help build-release build-dev publish test clean install-checkstyle lint scan scan-strict

pom.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@
5959
<version>2.2</version>
6060
<scope>test</scope>
6161
</dependency>
62+
<dependency>
63+
<groupId>org.jetbrains</groupId>
64+
<artifactId>annotations</artifactId>
65+
<version>23.0.0</version>
66+
<scope>test</scope>
67+
</dependency>
6268
<dependency>
6369
<groupId>com.easypost</groupId>
6470
<artifactId>easyvcr</artifactId>
@@ -252,6 +258,22 @@
252258
</execution>
253259
</executions>
254260
</plugin>
261+
<plugin>
262+
<groupId>org.owasp</groupId>
263+
<artifactId>dependency-check-maven</artifactId>
264+
<version>7.1.1</version>
265+
<configuration>
266+
<failBuildOnCVSS>7</failBuildOnCVSS>
267+
<junitFailOnCVSS>7</junitFailOnCVSS>
268+
</configuration>
269+
<executions>
270+
<execution>
271+
<goals>
272+
<goal>check</goal>
273+
</goals>
274+
</execution>
275+
</executions>
276+
</plugin>
255277
</plugins>
256278
</build>
257279
</project>

0 commit comments

Comments
 (0)