Skip to content

Commit dc2fd1e

Browse files
authored
Add Semgrep, Dependabot, and Snyk workflows (#565)
1 parent 9b16eca commit dc2fd1e

5 files changed

Lines changed: 118 additions & 9 deletions

File tree

.github/dependabot.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
8+
- package-ecosystem: "gradle"
9+
directory: "lib"
10+
schedule:
11+
interval: "daily"
12+
ignore:
13+
- dependency-name: "*"
14+
update-types: ["version-update:semver-major"]

.github/workflows/semgrep.yml

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,48 @@
11
name: Semgrep
22

33
on:
4-
pull_request: {}
5-
4+
merge_group:
5+
pull_request_target:
6+
types:
7+
- opened
8+
- synchronize
69
push:
7-
branches: ["master", "main"]
8-
10+
branches:
11+
- master
912
schedule:
1013
- cron: '30 0 1,15 * *'
1114

15+
permissions:
16+
contents: read
17+
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
20+
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
21+
1222
jobs:
13-
semgrep:
14-
name: Scan
23+
authorize:
24+
name: Authorize
25+
environment: ${{ github.actor != 'dependabot[bot]' && github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository && 'external' || 'internal' }}
1526
runs-on: ubuntu-latest
27+
steps:
28+
- run: true
29+
30+
run:
31+
needs: authorize # Require approval before running on forked pull requests
32+
33+
name: Check for Vulnerabilities
34+
runs-on: ubuntu-latest
35+
1636
container:
1737
image: returntocorp/semgrep
18-
if: (github.actor != 'dependabot[bot]')
38+
1939
steps:
20-
- uses: actions/checkout@v3
40+
- if: github.actor == 'dependabot[bot]' || github.event_name == 'merge_group'
41+
run: exit 0 # Skip unnecessary test runs for dependabot and merge queues. Artifically flag as successful, as this is a required check for branch protection.
42+
43+
- uses: actions/checkout@v4
44+
with:
45+
ref: ${{ github.event.pull_request.head.sha || github.ref }}
2146

2247
- run: semgrep ci
2348
env:

.github/workflows/snyk.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Snyk
2+
3+
on:
4+
merge_group:
5+
workflow_dispatch:
6+
pull_request:
7+
types:
8+
- opened
9+
- synchronize
10+
push:
11+
branches:
12+
- master
13+
schedule:
14+
- cron: '30 0 1,15 * *'
15+
16+
permissions:
17+
contents: read
18+
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
21+
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
22+
23+
jobs:
24+
authorize:
25+
name: Authorize
26+
environment: ${{ github.actor != 'dependabot[bot]' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository && 'external' || 'internal' }}
27+
runs-on: ubuntu-latest
28+
steps:
29+
- run: true
30+
31+
check:
32+
needs: authorize
33+
34+
name: Check for Vulnerabilities
35+
runs-on: ubuntu-latest
36+
37+
steps:
38+
- if: github.actor == 'dependabot[bot]' || github.event_name == 'merge_group'
39+
run: exit 0 # Skip unnecessary test runs for dependabot and merge queues. Artifically flag as successful, as this is a required check for branch protection.
40+
41+
- uses: actions/checkout@v4
42+
with:
43+
ref: ${{ github.event.pull_request.head.sha || github.ref }}
44+
45+
- uses: snyk/actions/gradle-jdk11@b98d498629f1c368650224d6d212bf7dfa89e4bf # pin@0.4.0
46+
env:
47+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}

.snyk

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
2+
version: v1.25.0
3+
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
4+
ignore:
5+
SNYK-JAVA-ORGJETBRAINSKOTLIN-2393744:
6+
- '*':
7+
reason: 'unaffected, only affects createTempFile and createTempDir kotlin function, which are not used'
8+
expires: 2023-12-31T00:00:00.000Z
9+
SNYK-JAVA-ORGBOUNCYCASTLE-5771339:
10+
- '*':
11+
reason: 'test-only dependency, no update available'
12+
expires: 2023-12-31T00:00:00.000Z
13+
14+
patch: {}

build.gradle

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,21 @@ dependencies {
8181
implementation "com.auth0:java-jwt:4.4.0"
8282
implementation "net.jodah:failsafe:2.4.4"
8383

84-
testImplementation "org.bouncycastle:bcprov-jdk15on:1.68"
84+
testImplementation "org.bouncycastle:bcprov-jdk15on:1.70"
8585
testImplementation "org.mockito:mockito-core:4.8.1"
8686
testImplementation "com.squareup.okhttp3:mockwebserver:${okhttpVersion}"
8787
testImplementation "org.hamcrest:hamcrest:${hamcrestVersion}"
8888
testImplementation "org.junit.jupiter:junit-jupiter-api:${jupiterVersion}"
8989
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${jupiterVersion}"
90+
91+
// Override MockWebServer's junit transitive dependency to latest v4
92+
constraints {
93+
testImplementation( group: 'junit', name: 'junit'){
94+
version{
95+
strictly "[4.13.2]"
96+
}
97+
}
98+
}
9099
}
91100

92101
// Creates a version.txt file containing the current version of the SDK.

0 commit comments

Comments
 (0)