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/update copyleft policy #63

Merged
merged 3 commits into from
Aug 14, 2024
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
13 changes: 13 additions & 0 deletions __tests__/copyleft-policy-check.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,17 @@ describe('CopyleftPolicyCheck', () => {
await policyCheck.run(scannerResults);
expect(policyCheck.conclusion).toEqual(CONCLUSION.Neutral);
});

it('should fail the policy check when copyleft dependencies are found', async () => {
scannerResults = JSON.parse(resultsMock[4].content);
await policyCheck.run(scannerResults);
// NEUTRAL is the same as failure in this context. See inputs.POLICIES_HALT_ON_FAILURE. (Default FALSE)
expect(policyCheck.conclusion).toEqual(CONCLUSION.Neutral);
});

it('should pass the copyleft policy check', async () => {
scannerResults = JSON.parse(resultsMock[5].content);
await policyCheck.run(scannerResults);
expect(policyCheck.conclusion).toEqual(CONCLUSION.Success);
});
});
12 changes: 12 additions & 0 deletions __tests__/results.mock.ts

Large diffs are not rendered by default.

25 changes: 24 additions & 1 deletion dist/index.js

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

4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "scanoss-code-scan-action",
"description": "SCANOSS Code Scan Action",
"version": "0.1.2",
"version": "0.1.3",
"author": "SCANOSS",
"private": true,
"homepage": "https://github.com/scanoss/code-scan-action/",
Expand Down
30 changes: 29 additions & 1 deletion src/policies/copyleft-policy-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,32 @@ import { generateTable } from '../utils/markdown.utils';
* It then generates a summary and detailed report of the findings.
*/
export class CopyleftPolicyCheck extends PolicyCheck {
private copyleftLicenses = new Set<string>(
[
'GPL-1.0-only',
'GPL-2.0-only',
'GPL-3.0-only',
'AGPL-3.0-only',
'Sleepycat',
'Watcom-1.0',
'GFDL-1.1-only',
'GFDL-1.2-only',
'GFDL-1.3-only',
'LGPL-2.1-only',
'LGPL-3.0-only',
'MPL-1.1',
'MPL-2.0',
'EPL-1.0',
'EPL-2.0',
'CDDL-1.0',
'CDDL-1.1',
'CECILL-2.1',
'Artistic-1.0',
'Artistic-2.0',
'CC-BY-SA-4.0'
].map(l => l.toLowerCase())
);

constructor() {
super(`${CHECK_NAME}: Copyleft Policy`);
}
Expand All @@ -43,7 +69,9 @@ export class CopyleftPolicyCheck extends PolicyCheck {

// Filter copyleft components
const componentsWithCopyleft = components.filter(component =>
component.licenses.some(license => !!license.copyleft)
component.licenses.some(
license => !!license.copyleft || this.copyleftLicenses.has(license.spdxid.trim().toLowerCase())
)
);

const summary = this.getSummary(componentsWithCopyleft);
Expand Down
Loading