Skip to content

Commit e57fd2f

Browse files
authored
Add Coverity static analyzer scan (#25)
WE2-539 Signed-off-by: Raul Metsma <[email protected]>
1 parent 25e758b commit e57fd2f

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

.github/workflows/maven-build.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,49 @@ jobs:
2525

2626
- name: Test and package
2727
run: mvn --batch-mode package
28+
29+
coverity:
30+
name: Run Coverity tests
31+
if: contains(github.repository, 'web-eid/web-eid-authtoken-validation-java') && contains(github.ref, 'coverity_scan')
32+
runs-on: ubuntu-latest
33+
34+
env:
35+
TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
36+
PROJECTNAME: 'web-eid/web-eid-authtoken-validation-java'
37+
38+
steps:
39+
- uses: actions/checkout@v2
40+
41+
- uses: actions/setup-java@v1
42+
with:
43+
java-version: 1.8
44+
45+
- name: Cache Maven packages
46+
uses: actions/cache@v1
47+
with:
48+
path: ~/.m2
49+
key: ${{ runner.os }}-m2-v8-${{ hashFiles('**/pom.xml') }}
50+
restore-keys: ${{ runner.os }}-m2-v8
51+
52+
- name: Download Coverity Build Tool
53+
run: |
54+
curl --silent --data "token=$TOKEN&project=$PROJECTNAME" -o cov-analysis-linux64.tar.gz https://scan.coverity.com/download/cxx/linux64
55+
mkdir cov-analysis-linux64
56+
tar xzf cov-analysis-linux64.tar.gz --strip 1 -C cov-analysis-linux64
57+
58+
- name: Build
59+
run: |
60+
export PATH=$PWD/cov-analysis-linux64/bin:$PATH
61+
cov-build --dir cov-int mvn --batch-mode compile
62+
63+
- name: Submit the result to Coverity Scan
64+
run: |
65+
tar czvf upload.tgz cov-int
66+
curl --silent \
67+
--form project=$PROJECTNAME \
68+
--form token=$TOKEN \
69+
70+
71+
--form version=master \
72+
--form description="Github Actions CI build" \
73+
https://scan.coverity.com/builds?project=$PROJECTNAME

src/main/java/eu/webeid/security/validator/certvalidators/SubjectCertificateNotRevokedValidator.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ public void validateCertificateNotRevoked(X509Certificate subjectCertificate) th
105105
}
106106

107107
final BasicOCSPResp basicResponse = (BasicOCSPResp) response.getResponseObject();
108+
if (basicResponse == null) {
109+
throw new UserCertificateOCSPCheckFailedException("Missing Basic OCSP Response");
110+
}
108111
verifyOcspResponse(basicResponse, ocspService, certificateId);
109112
if (ocspService.doesSupportNonce()) {
110113
checkNonce(request, basicResponse);
@@ -173,6 +176,10 @@ private void verifyOcspResponse(BasicOCSPResp basicResponse, OcspService ocspSer
173176
private static void checkNonce(OCSPReq request, BasicOCSPResp response) throws UserCertificateOCSPCheckFailedException {
174177
final Extension requestNonce = request.getExtension(OCSPObjectIdentifiers.id_pkix_ocsp_nonce);
175178
final Extension responseNonce = response.getExtension(OCSPObjectIdentifiers.id_pkix_ocsp_nonce);
179+
if (requestNonce == null || responseNonce == null) {
180+
throw new UserCertificateOCSPCheckFailedException("OCSP request or response nonce extension missing, " +
181+
"possible replay attack");
182+
}
176183
if (!requestNonce.equals(responseNonce)) {
177184
throw new UserCertificateOCSPCheckFailedException("OCSP request and response nonces differ, " +
178185
"possible replay attack");

0 commit comments

Comments
 (0)