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

feat(scan): make reciprocal licenses configurable #13

Merged
merged 2 commits into from
Mar 28, 2024
Merged
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
11 changes: 10 additions & 1 deletion .github/workflows/pr-scan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ on:
required: false
type: string
default: ubuntu-latest
allow-reciprocal-licenses:
description: |
(Only applicable to private repositories)
Allows licenses classified as 'reciprocal' to be used.
required: false
type: boolean
default: true

jobs:
scan:
Expand Down Expand Up @@ -66,6 +73,7 @@ jobs:
id: config
env:
SEVERITY: ${{ inputs.fail_on_severity }}
ALLOW_RECIPROCAL_LICENSES: ${{ inputs.allow-reciprocal-licenses }}
with:
script: |-
const path = require('path');
Expand All @@ -88,13 +96,14 @@ jobs:
}

const privateRepo = context.payload?.repository?.private || false;
const isReciprocalLicenseAllowed = process.env.ALLOW_RECIPROCAL_LICENSES === 'true';

let licenseCfgFile = path.join(configsDir, 'license.yaml');
try {
const licenseCfg = yaml.load(fs.readFileSync(licenseCfgFile));
const allowedLicensesRaw = [];
allowedLicensesRaw.push(...licenseCfg.license.notice);
if (privateRepo) {
if (privateRepo && isReciprocalLicenseAllowed) {
allowedLicensesRaw.push(...licenseCfg.license.reciprocal);
}
// Filter out non-SPDX licenses
Expand Down
Loading