Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fixed trust store logic in verify #38

Merged
merged 13 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/e2e-test-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ jobs:
target_artifact_reference: ${{ env.target_artifact_reference }}
trust_policy: ./tests/e2e/trustpolicy/trustpolicy.json
trust_store: ./tests/e2e/truststore

- name: Verify released artifact again with the same notation configuration
uses: ./verify
with:
target_artifact_reference: ${{ env.target_artifact_reference }}
trust_policy: ./tests/e2e/trustpolicy/trustpolicy.json
trust_store: ./tests/e2e/truststore

- name: Verify released artifact missing target artifact reference
continue-on-error: true
Expand Down Expand Up @@ -143,8 +150,6 @@ jobs:
echo "Verify released artifact with invalid trust store structure should fail, but succeeded."
exit 1

- name: Clean up notation trust store
run: notation cert delete --type ca --store e2e-test -y --all
- name: Verify released artifact without valid cert in trust store
continue-on-error: true
id: invalid-cert
Expand Down
7 changes: 6 additions & 1 deletion dist/verify.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/verify.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import * as core from '@actions/core';
import * as exec from '@actions/exec';
import * as fs from 'fs';
import * as path from 'path';
import {getConfigHome} from './lib/install'

const X509 = "x509";

Expand Down Expand Up @@ -72,6 +73,10 @@ async function configTrustStore(dir: string) {
if (!fs.existsSync(trustStoreX509)) {
throw new Error(`cannot find trust store dir: ${trustStoreX509}`);
}
const trustStorePath = path.join(getConfigHome(), 'notation', 'truststore');
if (fs.existsSync(trustStorePath)) {
fs.rmSync(trustStorePath, {recursive: true});
}
let trustStoreTypes = getSubdir(trustStoreX509); // [.github/truststore/x509/ca, .github/truststore/x509/signingAuthority, ...]
for (let i = 0; i < trustStoreTypes.length; ++i) {
let trustStoreType = path.basename(trustStoreTypes[i]);
Expand All @@ -80,7 +85,7 @@ async function configTrustStore(dir: string) {
let trustStore = trustStores[j]; // .github/truststore/x509/ca/<my_store>
let trustStoreName = path.basename(trustStore); // <my_store>
let certFile = getFileFromDir(trustStore); // [.github/truststore/x509/ca/<my_store>/<my_cert1>, .github/truststore/x509/ca/<my_store>/<my_cert2>, ...]
exec.getExecOutput('notation', ['cert', 'add', '-t', trustStoreType, '-s', trustStoreName, ...certFile]);
await exec.getExecOutput('notation', ['cert', 'add', '-t', trustStoreType, '-s', trustStoreName, ...certFile]);
}
}
}
Expand Down
Loading