Skip to content

Commit 567b2bf

Browse files
authored
Initial commit (#1)
* Initial commit * bump * test with commonm version * change dependency version * fix version * Use node version * use zip artifact * move back to jar * update cache * bump * enable scanner * add releasability check * fix sq issues * more sq issues * fix sq issues * add exclusions
1 parent 34ca867 commit 567b2bf

File tree

13 files changed

+715
-20
lines changed

13 files changed

+715
-20
lines changed

.cirrus.yml

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,62 @@
11
env:
2-
CIRRUS_CLONE_DEPTH: "20"
32
CIRRUS_SHELL: bash
3+
CIRRUS_VAULT_URL: https://vault.sonar.build:8200
4+
CIRRUS_VAULT_AUTH_PATH: jwt-cirrusci
5+
CIRRUS_VAULT_ROLE: cirrusci-${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}
6+
7+
ARTIFACTORY_URL: https://repox.jfrog.io/artifactory
8+
ARTIFACTORY_PRIVATE_USERNAME: vault-${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-private-reader
9+
ARTIFACTORY_PRIVATE_PASSWORD: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-private-reader access_token]
10+
ARTIFACTORY_DEPLOY_USERNAME: vault-${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-qa-deployer
11+
ARTIFACTORY_DEPLOY_PASSWORD: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-qa-deployer access_token]
12+
ARTIFACTORY_DEPLOY_REPO: sonarsource-public-qa
13+
ARTIFACTORY_ACCESS_TOKEN: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-private-reader access_token]
14+
15+
only_sonarsource_qa: &ONLY_SONARSOURCE_QA
16+
only_if: $CIRRUS_USER_COLLABORATOR == 'true' && $CIRRUS_TAG == "" && ($CIRRUS_PR != "" || $CIRRUS_BRANCH == "master" || $CIRRUS_BRANCH =~ "branch-.*")
17+
18+
nodejs_runtimes_cache_definition: &RUNTIME_CACHE
19+
runtime_cache:
20+
folder: runtime/downloads/
21+
fingerprint_script: cat runtime/pom.xml | grep -o "<nodeVersion>.*"
422

523
eks_container_definition: &CONTAINER_DEFINITION
6-
image: ${CIRRUS_AWS_ACCOUNT}.dkr.ecr.eu-central-1.amazonaws.com/base:latest
24+
image: ${CIRRUS_AWS_ACCOUNT}.dkr.ecr.eu-central-1.amazonaws.com/base:j17-latest
725
cluster_name: ${CIRRUS_CLUSTER_NAME}
826
region: eu-central-1
927
namespace: default
1028

1129
build_task:
1230
eks_container:
1331
<<: *CONTAINER_DEFINITION
14-
cpu: 1
15-
memory: 1G
32+
cpu: 2
33+
memory: 2G
1634
env:
17-
# Possible values for ARTIFACTORY_DEPLOY_REPO: sonarsource-private-qa, sonarsource-public-qa
18-
ARTIFACTORY_DEPLOY_REPO: FIXME
19-
ARTIFACTORY_DEPLOY_USERNAME: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-qa-deployer username]
20-
ARTIFACTORY_DEPLOY_PASSWORD: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-qa-deployer access_token]
2135
DEPLOY_PULL_REQUEST: "true"
36+
SONAR_TOKEN: VAULT[development/kv/data/next data.token]
37+
SONAR_HOST_URL: https://next.sonarqube.com/sonarqube
38+
maven_cache:
39+
folder: ${CIRRUS_WORKING_DIR}/.m2/repository
40+
<<: *RUNTIME_CACHE
2241
build_script:
2342
- source cirrus-env BUILD
24-
- regular_build_...
43+
- regular_mvn_build_deploy_analyze
44+
cleanup_before_cache_script:
45+
- cleanup_maven_repository
2546

2647
promote_task:
2748
depends_on:
2849
- build
50+
<<: *ONLY_SONARSOURCE_QA
2951
eks_container:
3052
<<: *CONTAINER_DEFINITION
31-
cpu: 1
32-
memory: 1G
53+
cpu: 2
54+
memory: 2G
3355
env:
3456
ARTIFACTORY_PROMOTE_ACCESS_TOKEN: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-promoter access_token]
3557
GITHUB_TOKEN: VAULT[development/github/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-promotion token]
36-
ARTIFACTS: FIXME # This was for Burgr links, is it still required?
37-
script: cirrus_promote_...
58+
maven_cache:
59+
folder: $CIRRUS_WORKING_DIR/.m2/repository
60+
script: cirrus_promote_maven
61+
cleanup_before_cache_script:
62+
- cleanup_maven_repository
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Releasability status
2+
'on':
3+
check_suite:
4+
types:
5+
- completed
6+
jobs:
7+
update_releasability_status:
8+
runs-on: ubuntu-latest
9+
name: Releasability status
10+
permissions:
11+
id-token: write
12+
statuses: write
13+
contents: read
14+
if: >-
15+
(contains(fromJSON('["main", "master"]'),
16+
github.event.check_suite.head_branch) ||
17+
startsWith(github.event.check_suite.head_branch, 'dogfood-') ||
18+
startsWith(github.event.check_suite.head_branch, 'branch-')) &&
19+
github.event.check_suite.conclusion == 'success' &&
20+
github.event.check_suite.app.slug == 'cirrus-ci'
21+
steps:
22+
- uses: >-
23+
SonarSource/gh-action_releasability/releasability-status@v2
24+
with:
25+
optional_checks: "Jira"
26+
env:
27+
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'

.github/workflows/release.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
---
2-
name: Release
2+
name: sonar-release
3+
# This workflow is triggered when publishing a new github release
4+
# yamllint disable-line rule:truthy
35
on:
46
release:
57
types:
68
- published
79

8-
env:
9-
PYTHONUNBUFFERED: 1
10-
1110
jobs:
1211
release:
1312
permissions:
1413
id-token: write
1514
contents: write
16-
uses: SonarSource/gh-action_release/.github/workflows/main.yaml@34d8b20d125bfd58d124e84b007d3a18e61c358a # 5.10.4
15+
uses: SonarSource/gh-action_release/.github/workflows/main.yaml@v5
16+
with:
17+
publishToBinaries: true
18+
slackChannel: squad-web

.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Maven
2+
target/
3+
bin/
4+
5+
# IntelliJ IDEA
6+
*.iws
7+
*.iml
8+
*.ipr
9+
.idea/
10+
11+
# Eclipse
12+
.classpath
13+
.project
14+
.settings
15+
16+
# Visual Studio
17+
.vs/
18+
19+
# VS Code
20+
.vscode/
21+
22+
# ---- Mac OS X
23+
.DS_Store
24+
25+
# ---- Windows
26+
# Windows image file caches
27+
Thumbs.db
28+
# Folder config file
29+
Desktop.ini
30+
31+
# ---- Sonar
32+
.sonar
33+
.scannerwork
34+
35+
runtime/downloads
36+
**/.flattened-pom.xml

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1-
# nodejs-maven-plugin
1+
# Maven plugin dedicated to the SonarJS project lifecycle
22

3-
Maven plugin to provide Node.js runtimes
3+
## Goals
4+
5+
### `compress`
6+
7+
Compress the passed `filenames` using LZMA2 compression algorithm.
8+
9+
### `download-runtimes`
10+
11+
Download the Node.js runtimes and create their manifests (`version.txt`).

SECURITY.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Reporting Security Issues
2+
3+
A mature software vulnerability treatment process is a cornerstone of a robust information security management system.
4+
Contributions from the community play an important role in the evolution and security of our products, and in safeguarding
5+
the security and privacy of our users.
6+
7+
If you believe you have discovered a security vulnerability in Sonar's products, we encourage you to report it immediately.
8+
9+
To responsibly report a security issue, please email us at [[email protected]](mailto:[email protected]).
10+
Sonar’s security team will acknowledge your report, guide you through the next steps, or request additional information if necessary.
11+
Customers with a support contract can also report the vulnerability directly through the support channel.
12+
13+
For security vulnerabilities found in third-party libraries, please also contact the library's owner or maintainer directly.
14+
15+
## Responsible Disclosure Policy
16+
17+
For more information about disclosing a security vulnerability to Sonar, please refer to our community post: [Responsible Vulnerability Disclosure](https://community.sonarsource.com/t/responsible-vulnerability-disclosure/9317/).

maven-plugin/pom.xml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<parent>
6+
<groupId>org.sonarsource.nodejs</groupId>
7+
<artifactId>nodejs-maven</artifactId>
8+
<version>${revision}</version>
9+
</parent>
10+
11+
<artifactId>nodejs-maven-plugin</artifactId>
12+
<packaging>maven-plugin</packaging>
13+
<name>NodeJS Maven Plugin</name>
14+
<description>Maven plugin to provide NodeJS runtimes</description>
15+
<inceptionYear>2025</inceptionYear>
16+
<version>${revision}</version>
17+
18+
<properties>
19+
<maven-plugin-tools.version>3.15.1</maven-plugin-tools.version>
20+
<gitRepositoryName>nodejs-maven-plugin</gitRepositoryName>
21+
<jdk.min.version>17</jdk.min.version>
22+
<maven.compiler.source>17</maven.compiler.source>
23+
<maven.compiler.target>17</maven.compiler.target>
24+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
25+
</properties>
26+
27+
28+
<dependencies>
29+
<dependency>
30+
<groupId>org.apache.maven</groupId>
31+
<artifactId>maven-plugin-api</artifactId>
32+
<version>3.9.9</version>
33+
<scope>provided</scope>
34+
</dependency>
35+
<dependency>
36+
<groupId>org.apache.maven.plugin-tools</groupId>
37+
<artifactId>maven-plugin-annotations</artifactId>
38+
<version>${maven-plugin-tools.version}</version>
39+
<scope>provided</scope>
40+
</dependency>
41+
<dependency>
42+
<groupId>org.codehaus.plexus</groupId>
43+
<artifactId>plexus-archiver</artifactId>
44+
<version>4.10.0</version>
45+
</dependency>
46+
<dependency>
47+
<groupId>org.tukaani</groupId>
48+
<artifactId>xz</artifactId>
49+
<version>1.10</version>
50+
</dependency>
51+
</dependencies>
52+
</project>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* NodeJS Maven Plugin
3+
* Copyright (C) 2025-2025 SonarSource SA
4+
* mailto:info AT sonarsource DOT com
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the Sonar Source-Available License Version 1, as published by SonarSource SA.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12+
* See the Sonar Source-Available License for more details.
13+
*
14+
* You should have received a copy of the Sonar Source-Available License
15+
* along with this program; if not, see https://sonarsource.com/license/ssal/
16+
*/
17+
public class ChecksumException extends Exception {
18+
public ChecksumException(String message) {
19+
super(message);
20+
}
21+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* NodeJS Maven Plugin
3+
* Copyright (C) 2025-2025 SonarSource SA
4+
* mailto:info AT sonarsource DOT com
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the Sonar Source-Available License Version 1, as published by SonarSource SA.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12+
* See the Sonar Source-Available License for more details.
13+
*
14+
* You should have received a copy of the Sonar Source-Available License
15+
* along with this program; if not, see https://sonarsource.com/license/ssal/
16+
*/
17+
import java.io.FileNotFoundException;
18+
import java.io.IOException;
19+
import java.nio.file.Files;
20+
import java.nio.file.Path;
21+
import java.util.Arrays;
22+
import java.util.List;
23+
import org.apache.maven.plugin.AbstractMojo;
24+
import org.apache.maven.plugins.annotations.Mojo;
25+
import org.apache.maven.plugins.annotations.Parameter;
26+
import org.tukaani.xz.LZMA2Options;
27+
import org.tukaani.xz.XZOutputStream;
28+
29+
@Mojo(name = "compress")
30+
public class CompressMojo extends AbstractMojo {
31+
32+
@Parameter(required = true)
33+
private String baseDirectory;
34+
35+
@Parameter(required = true)
36+
private List<String> filenames;
37+
38+
@Parameter(required = true)
39+
private String targetDirectory;
40+
41+
@Parameter(defaultValue = "9")
42+
private int compressionLevel;
43+
44+
@Override
45+
public void execute() {
46+
try {
47+
this.compress(
48+
this.filenames.stream()
49+
.map(filename -> Path.of(this.baseDirectory, filename).toAbsolutePath())
50+
.toList()
51+
);
52+
} catch (IOException e) {
53+
throw new IllegalStateException(
54+
"Error while compressing " + Arrays.toString(filenames.toArray()),
55+
e
56+
);
57+
}
58+
}
59+
60+
protected void compress(List<Path> filenames) throws IOException {
61+
for (var file : filenames) {
62+
var outputFile = Path.of(
63+
this.targetDirectory,
64+
Path.of(this.baseDirectory).toAbsolutePath().relativize(file) + ".xz"
65+
);
66+
67+
this.getLog().info("Compressing " + file + " to " + outputFile);
68+
69+
if (!Files.exists(file)) {
70+
throw new FileNotFoundException(String.format("File %s does not exist.", file));
71+
}
72+
73+
if (Files.exists(outputFile)) {
74+
this.getLog()
75+
.info(String.format("Skipping compression, file %s already exists.", outputFile));
76+
continue;
77+
}
78+
79+
outputFile.toFile().getParentFile().mkdirs();
80+
81+
try (
82+
var is = Files.newInputStream(file);
83+
var outfile = Files.newOutputStream(outputFile);
84+
var outxz = new XZOutputStream(outfile, new LZMA2Options(this.compressionLevel))
85+
) {
86+
is.transferTo(outxz);
87+
}
88+
}
89+
}
90+
}

0 commit comments

Comments
 (0)