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

Added project for Vaadin core SBOM checks #7001

Merged
merged 6 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
38 changes: 36 additions & 2 deletions scripts/generateAndCheckSBOM.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const path = require('path');
const VAADIN_LICENSE = 'https://vaadin.com/commercial-license-and-service-terms';
const SBOM_URL = 'https://github.com/vaadin/platform/releases/download/%%VERSION%%/Software.Bill.Of.Materials.json'
const testProject = path.resolve('vaadin-platform-sbom');
const coreProject = path.resolve('vaadin-core-sbom');
edler-san marked this conversation as resolved.
Show resolved Hide resolved
const licenseWhiteList = [
'ISC',
'MIT',
Expand Down Expand Up @@ -89,7 +90,7 @@ pre[b] {border: solid 1px darkgrey}
</style>`;

const cmd = {
useBomber: true, useOSV: true, useOWASP: true,
useBomber: true, useOSV: true, useOWASP: true, checkCoreLicenses : true,
hasOssToken: !!(process.env.OSSINDEX_USER && process.env.OSSINDEX_TOKEN)
};
for (let i = 2, l = process.argv.length; i < l; i++) {
Expand All @@ -102,9 +103,10 @@ for (let i = 2, l = process.argv.length; i < l; i++) {
case '--version': cmd.version = process.argv[++i]; break;
case '--compare': cmd.org = process.argv[++i]; break;
case '--quick': cmd.quick = true; break;
case '--skip-check-core-licenses' : cmd.checkCoreLicenses = false; break;
default:
console.log(`Usage: ${path.relative('.', process.argv[1])}
[--useSnapshots] [--disable-bomber] [--disable-osv-scan] [--disable-owasp] [--enable-full-owasp] [--version x.x.x] [--quick]`);
[--useSnapshots] [--disable-bomber] [--disable-osv-scan] [--disable-owasp] [--enable-full-owasp] [--version x.x.x] [--quick] [--skip-check-core-licenses]`);
process.exit(1);
}
}
Expand Down Expand Up @@ -397,6 +399,12 @@ function checkLicenses(licenses) {
return ret;
}

function checkCoreLicenses(){
let ret="";
console.log("Starting license check for Vaadin Core.");
return ret;
}

function checkVunerabilities(vuls) {
let err = "", msg = "";
Object.keys(vuls).forEach(v => {
Expand Down Expand Up @@ -539,6 +547,16 @@ async function main() {
log(`cd ${testProject}`);
process.chdir(testProject);

let coreLicensesResult=undefined;
let coreLicenses=undefined;

if(cmd.checkCoreLicenses){
log(`generating Core SBOM`);
await run('mvn -ntp -B org.cyclonedx:cyclonedx-maven-plugin:makeAggregateBom -q -f ../vaadin-core-sbom');
edler-san marked this conversation as resolved.
Show resolved Hide resolved
coreLicenses = sumarizeLicenses('../vaadin-core-sbom/target/bom.json');
coreLicensesResult = checkLicenses(coreLicenses);
}

if (!cmd.quick) {
// Ensure package.json and node_modules are empty
await run('rm -rf package.json node_modules frontend src');
Expand Down Expand Up @@ -590,6 +608,8 @@ async function main() {
sumarizeOWASP('target/dependency-check-report.json', vulnerabilities);
}



const errLic = checkLicenses(licenses);
const errVul = checkVunerabilities(vulnerabilities).err;
const msgVul = checkVunerabilities(vulnerabilities).msg;
Expand Down Expand Up @@ -617,6 +637,20 @@ async function main() {
md += `\n### 🔒 No Vulnerabilities\n`;
html += `\n<h3>🔒 No Vulnerabilities</h3>\n`;
}

if (cmd.checkCoreLicenses) {
if (coreLicensesResult) {
md += `\n### 🚫 Found Core License Issues\n`;
html += `\n<h3>>🚫 Found Core License Issues</h3>\n`;
md += reportLicenses(coreLicenses).md;
html += reportLicenses(coreLicenses).html;
} else {
errMsg += `- 📔 No Core License Issues\n`;
md += `\n### 📔 CoreLicenses\n`;
html += `\n<h3>📔 Core Licenses</h3>\n`;
}
}

if (errLic) {
md += `\n### 🚫 Found License Issues\n`;
html += `\n<h3>>🚫 Found License Issues</h3>\n`;
Expand Down
44 changes: 44 additions & 0 deletions vaadin-core-sbom/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
edler-san marked this conversation as resolved.
Show resolved Hide resolved
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-platform-parent</artifactId>
<version>24.5.3</version>
</parent>
<artifactId>vaadin-core-sbom</artifactId>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-bom</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-core</artifactId>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>flow-webpush</artifactId>
</dependency>
</dependencies>
</project>
Loading