aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build.gradle10
-rw-r--r--server/sonar-alm-client/src/test/java/org/sonar/alm/client/gitlab/GitlabApplicationClientTest.java18
-rw-r--r--server/sonar-ce-common/src/main/java/org/sonar/ce/common/scanner/ScannerReportReader.java2
-rw-r--r--server/sonar-ce-common/src/testFixtures/java/org/sonar/ce/common/scanner/ScannerReportReaderRule.java12
-rw-r--r--server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/scanner/ScannerReportReaderImpl.java8
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/scanner/ScannerReportReaderImplTest.java8
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/sca/CliService.java16
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/sca/ScaExecutor.java2
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/sca/CliServiceTest.java102
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/sca/ScaExecutorTest.java20
-rw-r--r--sonar-scanner-engine/src/test/resources/org/sonar/scanner/sca/echo_args.bat2
-rwxr-xr-xsonar-scanner-engine/src/test/resources/org/sonar/scanner/sca/echo_args.sh2
-rw-r--r--sonar-scanner-protocol/src/it/java/org/sonar/scanner/protocol/output/ScannerReportReaderIT.java12
-rw-r--r--sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/FileStructure.java4
-rw-r--r--sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportReader.java8
15 files changed, 116 insertions, 110 deletions
diff --git a/build.gradle b/build.gradle
index 63be426037d..f187321d0ba 100644
--- a/build.gradle
+++ b/build.gradle
@@ -285,8 +285,8 @@ subprojects {
// bundled plugin list -- keep it alphabetically ordered
dependency 'com.sonarsource.abap:sonar-abap-plugin:3.15.1.6010'
dependency 'com.sonarsource.cobol:sonar-cobol-plugin:5.8.1.8428'
- dependency 'com.sonarsource.cpp:sonar-cfamily-dependencies-plugin:6.68.0.85760'
- dependency 'com.sonarsource.cpp:sonar-cfamily-plugin:6.68.0.85760'
+ dependency 'com.sonarsource.cpp:sonar-cfamily-dependencies-plugin:6.69.0.86956'
+ dependency 'com.sonarsource.cpp:sonar-cfamily-plugin:6.69.0.86956'
dependency 'com.sonarsource.dart:sonar-dart-plugin:1.3.0.2614'
dependency 'com.sonarsource.dbd:sonar-dbd-plugin:2.2.0.16530'
dependency 'com.sonarsource.dbd:sonar-dbd-java-frontend-plugin:2.2.0.16530'
@@ -317,15 +317,15 @@ subprojects {
dependency 'org.sonarsource.go:sonar-go-plugin:1.25.0.3305'
dependency 'org.sonarsource.html:sonar-html-plugin:3.19.0.5695'
dependency 'org.sonarsource.jacoco:sonar-jacoco-plugin:1.3.0.1538'
- dependency 'org.sonarsource.java:sonar-java-plugin:8.17.1.39878'
+ dependency 'org.sonarsource.java:sonar-java-plugin:8.18.0.40025'
dependency 'org.sonarsource.java:sonar-java-symbolic-execution-plugin:8.16.0.131'
- dependency 'org.sonarsource.javascript:sonar-javascript-plugin:11.0.0.33655'
+ dependency 'org.sonarsource.javascript:sonar-javascript-plugin:11.1.0.33853'
dependency 'org.sonarsource.php:sonar-php-plugin:3.46.0.13151'
dependency 'org.sonarsource.plugins.cayc:sonar-cayc-plugin:2.4.0.2018'
dependency 'org.sonarsource.python:sonar-python-plugin:5.5.0.23291'
dependency 'org.sonarsource.rust:sonar-rust-plugin:1.0.3.786'
dependency 'com.sonarsource.python:sonar-python-enterprise-plugin:5.5.0.23291'
- dependency 'org.sonarsource.kotlin:sonar-kotlin-plugin:3.2.0.7239'
+ dependency 'org.sonarsource.kotlin:sonar-kotlin-plugin:3.3.0.7402'
dependency "org.sonarsource.api.plugin:sonar-plugin-api:$pluginApiVersion"
dependency "org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures:$pluginApiVersion"
dependency 'org.sonarsource.xml:sonar-xml-plugin:2.13.0.5938'
diff --git a/server/sonar-alm-client/src/test/java/org/sonar/alm/client/gitlab/GitlabApplicationClientTest.java b/server/sonar-alm-client/src/test/java/org/sonar/alm/client/gitlab/GitlabApplicationClientTest.java
index 4ca698cd35d..43ef628cfdd 100644
--- a/server/sonar-alm-client/src/test/java/org/sonar/alm/client/gitlab/GitlabApplicationClientTest.java
+++ b/server/sonar-alm-client/src/test/java/org/sonar/alm/client/gitlab/GitlabApplicationClientTest.java
@@ -484,7 +484,8 @@ public class GitlabApplicationClientTest {
.hasMessage("Could not validate GitLab read permission. Got an unexpected answer.");
assertThat(logTester.logs(Level.INFO).get(0))
.contains("Gitlab API call to [" + server.url("/projects") + "] " +
- "failed with error message : [Failed to connect to " + server.getHostName());
+ "failed with error message : [Failed to connect to ")
+ .contains(server.getHostName());
}
@Test
@@ -496,7 +497,8 @@ public class GitlabApplicationClientTest {
.hasMessage("Could not validate GitLab token. Got an unexpected answer.");
assertThat(logTester.logs(Level.INFO).get(0))
.contains("Gitlab API call to [" + server.url("user") + "] " +
- "failed with error message : [Failed to connect to " + server.getHostName());
+ "failed with error message : [Failed to connect to ")
+ .contains(server.getHostName());
}
@Test
@@ -508,7 +510,8 @@ public class GitlabApplicationClientTest {
.hasMessage("Could not validate GitLab write permission. Got an unexpected answer.");
assertThat(logTester.logs(Level.INFO).get(0))
.contains("Gitlab API call to [" + server.url("/markdown") + "] " +
- "failed with error message : [Failed to connect to " + server.getHostName());
+ "failed with error message : [Failed to connect to ")
+ .contains(server.getHostName());
}
@Test
@@ -520,7 +523,8 @@ public class GitlabApplicationClientTest {
.hasMessageContaining("Failed to connect to");
assertThat(logTester.logs(Level.INFO).get(0))
.contains("Gitlab API call to [" + server.url("/projects/0") + "] " +
- "failed with error message : [Failed to connect to " + server.getHostName());
+ "failed with error message : [Failed to connect to ")
+ .contains( server.getHostName());
}
@Test
@@ -529,7 +533,8 @@ public class GitlabApplicationClientTest {
assertThatThrownBy(() -> underTest.getBranches(gitlabUrl, "token", 0L))
.isInstanceOf(IllegalStateException.class)
- .hasMessageContaining("Failed to connect to " + server.getHostName());
+ .hasMessageContaining("Failed to connect to ")
+ .hasMessageContaining(server.getHostName());
assertThat(logTester.logs(Level.INFO).get(0))
.contains("Gitlab API call to [" + server.url("/projects/0/repository/branches") + "] " +
"failed with error message : [Failed to connect to " + server.getHostName());
@@ -546,7 +551,8 @@ public class GitlabApplicationClientTest {
.contains(
"Gitlab API call to [" + server.url("/projects?archived=false&simple=true&membership=true&order_by=name&sort=asc&search=&page=1&per_page=1")
+ "] " +
- "failed with error message : [Failed to connect to " + server.getHostName());
+ "failed with error message : [Failed to connect to ")
+ .contains( server.getHostName());
}
@Test
diff --git a/server/sonar-ce-common/src/main/java/org/sonar/ce/common/scanner/ScannerReportReader.java b/server/sonar-ce-common/src/main/java/org/sonar/ce/common/scanner/ScannerReportReader.java
index 459ba57009a..925d57bb540 100644
--- a/server/sonar-ce-common/src/main/java/org/sonar/ce/common/scanner/ScannerReportReader.java
+++ b/server/sonar-ce-common/src/main/java/org/sonar/ce/common/scanner/ScannerReportReader.java
@@ -74,7 +74,7 @@ public interface ScannerReportReader {
CloseableIterator<ScannerReport.TelemetryEntry> readTelemetryEntries();
- File readDependencyFilesZip();
+ File readDependencyFilesArchive();
CloseableIterator<ScannerReport.AnalysisData> readAnalysisData();
}
diff --git a/server/sonar-ce-common/src/testFixtures/java/org/sonar/ce/common/scanner/ScannerReportReaderRule.java b/server/sonar-ce-common/src/testFixtures/java/org/sonar/ce/common/scanner/ScannerReportReaderRule.java
index 29e718bfe96..5887533d74e 100644
--- a/server/sonar-ce-common/src/testFixtures/java/org/sonar/ce/common/scanner/ScannerReportReaderRule.java
+++ b/server/sonar-ce-common/src/testFixtures/java/org/sonar/ce/common/scanner/ScannerReportReaderRule.java
@@ -64,7 +64,7 @@ public class ScannerReportReaderRule implements TestRule, ScannerReportReader, A
private List<ScannerReport.AnalysisWarning> analysisWarnings = Collections.emptyList();
private byte[] analysisCache;
private List<ScannerReport.TelemetryEntry> telemetryEntries = new ArrayList<>();
- private File dependencyFilesZip;
+ private File dependencyFilesArchive;
private List<ScannerReport.AnalysisData> analysisData = new ArrayList<>();
@Override
@@ -347,15 +347,15 @@ public class ScannerReportReaderRule implements TestRule, ScannerReportReader, A
}
@Override
- public File readDependencyFilesZip() {
- if (dependencyFilesZip == null) {
+ public File readDependencyFilesArchive() {
+ if (dependencyFilesArchive == null) {
return null;
}
- return this.dependencyFilesZip;
+ return this.dependencyFilesArchive;
}
- public ScannerReportReaderRule putDependencyFilesZip(File dependencyFilesZip) {
- this.dependencyFilesZip = dependencyFilesZip;
+ public ScannerReportReaderRule putDependencyFilesArchive(File dependencyFilesArchive) {
+ this.dependencyFilesArchive = dependencyFilesArchive;
return this;
}
}
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/scanner/ScannerReportReaderImpl.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/scanner/ScannerReportReaderImpl.java
index 5f2627c31a0..fb39308cd00 100644
--- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/scanner/ScannerReportReaderImpl.java
+++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/scanner/ScannerReportReaderImpl.java
@@ -19,8 +19,6 @@
*/
package org.sonar.ce.task.projectanalysis.scanner;
-import static java.nio.charset.StandardCharsets.UTF_8;
-
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -38,6 +36,8 @@ import org.sonar.scanner.protocol.output.FileStructure;
import org.sonar.scanner.protocol.output.ScannerReport;
import org.sonar.scanner.protocol.output.ScannerReport.LineSgnificantCode;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
public class ScannerReportReaderImpl implements ScannerReportReader {
private final ScannerReportDirectoryHolder scannerReportDirectoryHolder;
@@ -235,9 +235,9 @@ public class ScannerReportReaderImpl implements ScannerReportReader {
}
@Override
- public File readDependencyFilesZip() {
+ public File readDependencyFilesArchive() {
ensureInitialized();
- return delegate.readDependencyFilesZip();
+ return delegate.readDependencyFilesArchive();
}
@Override
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/scanner/ScannerReportReaderImplTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/scanner/ScannerReportReaderImplTest.java
index 6abf97d1ba9..d954d5eb819 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/scanner/ScannerReportReaderImplTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/scanner/ScannerReportReaderImplTest.java
@@ -303,9 +303,9 @@ public class ScannerReportReaderImplTest {
}
@Test
- public void verify_readDependencyFilesZip() throws IOException {
+ public void verify_readDependencyFilesArchive() throws IOException {
File tempDir = tempFolder.newDir();
- File tempFile = new File(tempDir, "dependency-files.zip");
+ File tempFile = new File(tempDir, "dependency-files.tar.xz");
byte[] expectedBytes = "hello world!".getBytes();
try (FileOutputStream fos = new FileOutputStream(tempFile)) {
fos.write(expectedBytes);
@@ -313,8 +313,8 @@ public class ScannerReportReaderImplTest {
writer.writeScaFile(tempFile);
- assertThat(underTest.readDependencyFilesZip()).isNotNull();
- var returnBytes = FileUtils.readFileToByteArray(underTest.readDependencyFilesZip());
+ assertThat(underTest.readDependencyFilesArchive()).isNotNull();
+ var returnBytes = FileUtils.readFileToByteArray(underTest.readDependencyFilesArchive());
assertThat(returnBytes).isEqualTo(expectedBytes);
}
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sca/CliService.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sca/CliService.java
index 1b2346f2b62..6b3418a8f6a 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sca/CliService.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sca/CliService.java
@@ -76,19 +76,19 @@ public class CliService {
this.projectExclusionFilters = projectExclusionFilters;
}
- public File generateManifestsZip(DefaultInputModule module, File cliExecutable, DefaultConfiguration configuration) throws IOException, IllegalStateException {
+ public File generateManifestsArchive(DefaultInputModule module, File cliExecutable, DefaultConfiguration configuration) throws IOException, IllegalStateException {
long startTime = system2.now();
boolean success = false;
try {
- String zipName = "dependency-files.zip";
- Path zipPath = module.getWorkDir().resolve(zipName);
+ String archiveName = "dependency-files.tar.xz";
+ Path archivePath = module.getWorkDir().resolve(archiveName);
List<String> args = new ArrayList<>();
args.add(cliExecutable.getAbsolutePath());
args.add("projects");
args.add("save-lockfiles");
- args.add("--zip");
- args.add("--zip-filename");
- args.add(zipPath.toAbsolutePath().toString());
+ args.add("--xz");
+ args.add("--xz-filename");
+ args.add(archivePath.toAbsolutePath().toString());
args.add("--directory");
args.add(module.getBaseDir().toString());
args.add("--recursive");
@@ -117,9 +117,9 @@ public class CliService {
Consumer<String> logConsumer = LOG.atLevel(Level.INFO)::log;
processWrapperFactory.create(module.getWorkDir(), logConsumer, logConsumer, envProperties, args.toArray(new String[0])).execute();
- LOG.info("Generated manifests zip file: {}", zipName);
+ LOG.info("Generated manifests archive file: {}", archiveName);
success = true;
- return zipPath.toFile();
+ return archivePath.toFile();
} finally {
telemetryCache.put("scanner.sca.execution.cli.duration", String.valueOf(system2.now() - startTime));
telemetryCache.put("scanner.sca.execution.cli.success", String.valueOf(success));
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sca/ScaExecutor.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sca/ScaExecutor.java
index 52a99673e43..143e144c2dc 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/sca/ScaExecutor.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/sca/ScaExecutor.java
@@ -75,7 +75,7 @@ public class ScaExecutor {
LOG.info("Collecting manifests for the dependency analysis...");
if (cliFile.exists()) {
try {
- File generatedZip = cliService.generateManifestsZip(root, cliFile, configuration);
+ File generatedZip = cliService.generateManifestsArchive(root, cliFile, configuration);
LOG.debug("Zip ready for report: {}", generatedZip);
reportPublisher.getWriter().writeScaFile(generatedZip);
LOG.debug("Manifest zip written to report");
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/sca/CliServiceTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/sca/CliServiceTest.java
index 86958228c34..33cf6c146e6 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/sca/CliServiceTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/sca/CliServiceTest.java
@@ -103,22 +103,22 @@ class CliServiceTest {
}
@Test
- void generateZip_shouldCallProcessCorrectly_andRegisterTelemetry() throws IOException, URISyntaxException {
+ void generateManifestsArchive_shouldCallProcessCorrectly_andRegisterTelemetry() throws IOException, URISyntaxException {
assertThat(rootModuleDir.resolve("test_file").toFile().createNewFile()).isTrue();
when(configuration.getProperties()).thenReturn(Map.of(CliService.SCA_EXCLUSIONS_KEY, "foo,bar,baz/**"));
when(configuration.getStringArray(CliService.SCA_EXCLUSIONS_KEY)).thenReturn(new String[] {"foo", "bar", "baz/**"});
- File producedZip = underTest.generateManifestsZip(rootInputModule, scriptDir(), configuration);
+ File producedArchive = underTest.generateManifestsArchive(rootInputModule, scriptDir(), configuration);
- assertThat(producedZip).exists();
+ assertThat(producedArchive).exists();
var expectedArguments = List.of(
"projects",
"save-lockfiles",
- "--zip",
- "--zip-filename",
- rootInputModule.getWorkDir().resolve("dependency-files.zip").toString(),
+ "--xz",
+ "--xz-filename",
+ rootInputModule.getWorkDir().resolve("dependency-files.tar.xz").toString(),
"--directory",
rootInputModule.getBaseDir().toString(),
"--recursive",
@@ -129,26 +129,26 @@ class CliServiceTest {
.contains("Arguments Passed In: " + String.join(" ", expectedArguments))
.contains("TIDELIFT_SKIP_UPDATE_CHECK=1")
.contains("TIDELIFT_ALLOW_MANIFEST_FAILURES=1")
- .contains("Generated manifests zip file: " + producedZip.getName());
+ .contains("Generated manifests archive file: " + producedArchive.getName());
assertThat(telemetryCache.getAll()).containsKey("scanner.sca.execution.cli.duration").isNotNull();
assertThat(telemetryCache.getAll()).containsEntry("scanner.sca.execution.cli.success", "true");
}
@Test
- void generateZip_whenDebugLogLevelAndScaDebugNotEnabled_shouldWriteDebugLogsToDebugStream() throws IOException, URISyntaxException {
+ void generateManifestsArchive_whenDebugLogLevelAndScaDebugNotEnabled_shouldWriteDebugLogsToDebugStream() throws IOException, URISyntaxException {
logTester.setLevel(DEBUG);
assertThat(rootModuleDir.resolve("test_file").toFile().createNewFile()).isTrue();
- underTest.generateManifestsZip(rootInputModule, scriptDir(), configuration);
+ underTest.generateManifestsArchive(rootInputModule, scriptDir(), configuration);
var expectedArguments = List.of(
"projects",
"save-lockfiles",
- "--zip",
- "--zip-filename",
- rootInputModule.getWorkDir().resolve("dependency-files.zip").toString(),
+ "--xz",
+ "--xz-filename",
+ rootInputModule.getWorkDir().resolve("dependency-files.tar.xz").toString(),
"--directory",
rootInputModule.getBaseDir().toString(),
"--recursive",
@@ -161,17 +161,17 @@ class CliServiceTest {
}
@Test
- void generateZip_whenScaDebugEnabled_shouldWriteDebugLogsToInfoStream() throws IOException, URISyntaxException {
+ void generateManifestsArchive_whenScaDebugEnabled_shouldWriteDebugLogsToInfoStream() throws IOException, URISyntaxException {
assertThat(rootModuleDir.resolve("test_file").toFile().createNewFile()).isTrue();
- underTest.generateManifestsZip(rootInputModule, scriptDir(), configuration);
+ underTest.generateManifestsArchive(rootInputModule, scriptDir(), configuration);
var expectedArguments = List.of(
"projects",
"save-lockfiles",
- "--zip",
- "--zip-filename",
- rootInputModule.getWorkDir().resolve("dependency-files.zip").toString(),
+ "--xz",
+ "--xz-filename",
+ rootInputModule.getWorkDir().resolve("dependency-files.tar.xz").toString(),
"--directory",
rootInputModule.getBaseDir().toString(),
"--recursive",
@@ -183,8 +183,8 @@ class CliServiceTest {
}
@Test
- void generateZip_shouldSendSQEnvVars() throws IOException, URISyntaxException {
- underTest.generateManifestsZip(rootInputModule, scriptDir(), configuration);
+ void generateManifestsArchive_shouldSendSQEnvVars() throws IOException, URISyntaxException {
+ underTest.generateManifestsArchive(rootInputModule, scriptDir(), configuration);
assertThat(logTester.logs(INFO))
.contains("TIDELIFT_CLI_INSIDE_SCANNER_ENGINE=1")
@@ -192,15 +192,15 @@ class CliServiceTest {
}
@Test
- void generateZip_includesIgnoredPathsFromGitProvider() throws Exception {
- underTest.generateManifestsZip(rootInputModule, scriptDir(), configuration);
+ void generateManifestsArchive_includesIgnoredPathsFromGitProvider() throws Exception {
+ underTest.generateManifestsArchive(rootInputModule, scriptDir(), configuration);
var expectedArguments = List.of(
"projects",
"save-lockfiles",
- "--zip",
- "--zip-filename",
- rootInputModule.getWorkDir().resolve("dependency-files.zip").toString(),
+ "--xz",
+ "--xz-filename",
+ rootInputModule.getWorkDir().resolve("dependency-files.tar.xz").toString(),
"--directory",
rootInputModule.getBaseDir().toString(),
"--recursive",
@@ -217,61 +217,61 @@ class CliServiceTest {
}
@Test
- void generateZip_withNoScm_doesNotIncludeScmIgnoredPaths() throws Exception {
+ void generateManifestsArchive_withNoScm_doesNotIncludeScmIgnoredPaths() throws Exception {
when(scmConfiguration.provider()).thenReturn(null);
- underTest.generateManifestsZip(rootInputModule, scriptDir(), configuration);
+ underTest.generateManifestsArchive(rootInputModule, scriptDir(), configuration);
String capturedArgs = logTester.logs().stream().filter(log -> log.contains("Arguments Passed In:")).findFirst().get();
assertThat(capturedArgs).contains("--exclude .scannerwork/**");
}
@Test
- void generateZip_withNonGit_doesNotIncludeScmIgnoredPaths() throws Exception {
+ void generateManifestsArchive_withNonGit_doesNotIncludeScmIgnoredPaths() throws Exception {
when(scmProvider.key()).thenReturn("notgit");
- underTest.generateManifestsZip(rootInputModule, scriptDir(), configuration);
+ underTest.generateManifestsArchive(rootInputModule, scriptDir(), configuration);
String capturedArgs = logTester.logs().stream().filter(log -> log.contains("Arguments Passed In:")).findFirst().get();
assertThat(capturedArgs).contains("--exclude .scannerwork/**");
}
@Test
- void generateZip_withScmExclusionDisabled_doesNotIncludeScmIgnoredPaths() throws Exception {
+ void generateManifestsArchive_withScmExclusionDisabled_doesNotIncludeScmIgnoredPaths() throws Exception {
when(scmConfiguration.isExclusionDisabled()).thenReturn(true);
- underTest.generateManifestsZip(rootInputModule, scriptDir(), configuration);
+ underTest.generateManifestsArchive(rootInputModule, scriptDir(), configuration);
String capturedArgs = logTester.logs().stream().filter(log -> log.contains("Arguments Passed In:")).findFirst().get();
assertThat(capturedArgs).contains("--exclude .scannerwork/**");
}
@Test
- void generateZip_withNoScmIgnores_doesNotIncludeScmIgnoredPaths() throws Exception {
+ void generateManifestsArchive_withNoScmIgnores_doesNotIncludeScmIgnoredPaths() throws Exception {
jGitUtilsMock.when(() -> JGitUtils.getAllIgnoredPaths(any(Path.class))).thenReturn(List.of());
- underTest.generateManifestsZip(rootInputModule, scriptDir(), configuration);
+ underTest.generateManifestsArchive(rootInputModule, scriptDir(), configuration);
String capturedArgs = logTester.logs().stream().filter(log -> log.contains("Arguments Passed In:")).findFirst().get();
assertThat(capturedArgs).contains("--exclude .scannerwork/**");
}
@Test
- void generateZip_withExcludedManifests_appendsScmIgnoredPaths() throws Exception {
+ void generateManifestsArchive_withExcludedManifests_appendsScmIgnoredPaths() throws Exception {
when(configuration.getStringArray(CliService.SCA_EXCLUSIONS_KEY)).thenReturn(new String[] {"**/test/**"});
- underTest.generateManifestsZip(rootInputModule, scriptDir(), configuration);
+ underTest.generateManifestsArchive(rootInputModule, scriptDir(), configuration);
String capturedArgs = logTester.logs().stream().filter(log -> log.contains("Arguments Passed In:")).findFirst().get();
assertThat(capturedArgs).contains("--exclude **/test/**,ignored.txt,.scannerwork/**");
}
@Test
- void generateZip_withExcludedManifestsContainingBadCharacters_handlesTheBadCharacters() throws Exception {
+ void generateManifestsArchive_withExcludedManifestsContainingBadCharacters_handlesTheBadCharacters() throws Exception {
when(configuration.getStringArray(CliService.SCA_EXCLUSIONS_KEY)).thenReturn(new String[] {
"**/test/**", "**/path with spaces/**", "**/path'with'quotes/**", "**/path\"with\"double\"quotes/**"});
- underTest.generateManifestsZip(rootInputModule, scriptDir(), configuration);
+ underTest.generateManifestsArchive(rootInputModule, scriptDir(), configuration);
String capturedArgs = logTester.logs().stream().filter(log -> log.contains("Arguments Passed In:")).findFirst().get();
@@ -280,41 +280,41 @@ class CliServiceTest {
""".strip();
if (SystemUtils.IS_OS_WINDOWS) {
expectedExcludeFlag = """
- --exclude "**/test/**,**/path with spaces/**,**/path'with'quotes/**,"**/path""with""double""quotes/**",ignored.txt
- """.strip();
+ --exclude "**/test/**,**/path with spaces/**,**/path'with'quotes/**,"**/path""with""double""quotes/**",ignored.txt
+ """.strip();
}
assertThat(capturedArgs).contains(expectedExcludeFlag);
}
@Test
- void generateZip_withExcludedManifestsContainingDupes_dedupes() throws Exception {
+ void generateManifestsArchive_withExcludedManifestsContainingDupes_dedupes() throws Exception {
when(configuration.getStringArray(CliService.SCA_EXCLUSIONS_KEY)).thenReturn(new String[] {"**/test1/**", "**/test2/**", "**/test1/**"});
when(configuration.getStringArray(CliService.LEGACY_SCA_EXCLUSIONS_KEY)).thenReturn(new String[] {"**/test1/**", "**/test3/**"});
- underTest.generateManifestsZip(rootInputModule, scriptDir(), configuration);
+ underTest.generateManifestsArchive(rootInputModule, scriptDir(), configuration);
String capturedArgs = logTester.logs().stream().filter(log -> log.contains("Arguments Passed In:")).findFirst().get();
assertThat(capturedArgs).contains("--exclude **/test1/**,**/test2/**,**/test3/**,ignored.txt,.scannerwork/**");
}
@Test
- void generateZip_withExcludedManifestsAndSonarExcludesContainingDupes_mergesAndDedupes() throws Exception {
+ void generateManifestsArchive_withExcludedManifestsAndSonarExcludesContainingDupes_mergesAndDedupes() throws Exception {
when(projectExclusionFilters.getExclusionsConfig(InputFile.Type.MAIN)).thenReturn(new String[] {"**/test1/**", "**/test4/**"});
when(configuration.getStringArray(CliService.SCA_EXCLUSIONS_KEY)).thenReturn(new String[] {"**/test1/**", "**/test2/**", "**/test1/**"});
when(configuration.getStringArray(CliService.LEGACY_SCA_EXCLUSIONS_KEY)).thenReturn(new String[] {"**/test1/**", "**/test3/**"});
- underTest.generateManifestsZip(rootInputModule, scriptDir(), configuration);
+ underTest.generateManifestsArchive(rootInputModule, scriptDir(), configuration);
String capturedArgs = logTester.logs().stream().filter(log -> log.contains("Arguments Passed In:")).findFirst().get();
assertThat(capturedArgs).contains("--exclude **/test1/**,**/test4/**,**/test2/**,**/test3/**,ignored.txt,.scannerwork/**");
}
@Test
- void generateZip_withScmIgnoresContainingBadCharacters_handlesTheBadCharacters() throws Exception {
+ void generateManifestsArchive_withScmIgnoresContainingBadCharacters_handlesTheBadCharacters() throws Exception {
jGitUtilsMock.when(() -> JGitUtils.getAllIgnoredPaths(any(Path.class)))
.thenReturn(List.of("**/test/**", "**/path with spaces/**", "**/path'with'quotes/**", "**/path\"with\"double\"quotes/**"));
- underTest.generateManifestsZip(rootInputModule, scriptDir(), configuration);
+ underTest.generateManifestsArchive(rootInputModule, scriptDir(), configuration);
String capturedArgs = logTester.logs().stream().filter(log -> log.contains("Arguments Passed In:")).findFirst().get();
@@ -323,14 +323,14 @@ class CliServiceTest {
""".strip();
if (SystemUtils.IS_OS_WINDOWS) {
expectedExcludeFlag = """
- --exclude "**/test/**,**/path with spaces/**,**/path'with'quotes/**,"**/path""with""double""quotes/**"
- """.strip();
+ --exclude "**/test/**,**/path with spaces/**,**/path'with'quotes/**,"**/path""with""double""quotes/**"
+ """.strip();
}
assertThat(capturedArgs).contains(expectedExcludeFlag);
}
@Test
- void generateZip_withIgnoredDirectories_GlobifiesDirectories() throws Exception {
+ void generateManifestsArchive_withIgnoredDirectories_GlobifiesDirectories() throws Exception {
String ignoredDirectory = "directory1";
Files.createDirectories(rootModuleDir.resolve(ignoredDirectory));
String ignoredFile = "directory2/file.txt";
@@ -339,18 +339,18 @@ class CliServiceTest {
Files.createFile(ignoredFilePath);
jGitUtilsMock.when(() -> JGitUtils.getAllIgnoredPaths(any(Path.class))).thenReturn(List.of(ignoredDirectory, ignoredFile));
- underTest.generateManifestsZip(rootInputModule, scriptDir(), configuration);
+ underTest.generateManifestsArchive(rootInputModule, scriptDir(), configuration);
String capturedArgs = logTester.logs().stream().filter(log -> log.contains("Arguments Passed In:")).findFirst().get();
assertThat(capturedArgs).contains("--exclude directory1/**,directory2/file.txt");
}
@Test
- void generateZip_withExternalWorkDir_DoesNotExcludeWorkingDir() throws URISyntaxException, IOException {
+ void generateManifestsArchive_withExternalWorkDir_DoesNotExcludeWorkingDir() throws URISyntaxException, IOException {
Path externalWorkDir = Files.createTempDirectory("externalWorkDir");
try {
rootInputModule = new DefaultInputModule(ProjectDefinition.create().setBaseDir(rootModuleDir.toFile()).setWorkDir(externalWorkDir.toFile()));
- underTest.generateManifestsZip(rootInputModule, scriptDir(), configuration);
+ underTest.generateManifestsArchive(rootInputModule, scriptDir(), configuration);
String capturedArgs = logTester.logs().stream().filter(log -> log.contains("Arguments Passed In:")).findFirst().get();
// externalWorkDir is not present in the exclude flag
@@ -363,7 +363,7 @@ class CliServiceTest {
private URL scriptUrl() {
// There is a custom test Bash script available in src/test/resources/org/sonar/scanner/sca that
// will serve as our "CLI". This script will output some messages about what arguments were passed
- // to it and will try to generate a zip file in the location the process specifies. This allows us
+ // to it and will try to generate an archive file in the location the process specifies. This allows us
// to simulate a real CLI call without needing an OS specific CLI executable to run on a real project.
URL scriptUrl = CliServiceTest.class.getResource(SystemUtils.IS_OS_WINDOWS ? "echo_args.bat" : "echo_args.sh");
assertThat(scriptUrl).isNotNull();
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/sca/ScaExecutorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/sca/ScaExecutorTest.java
index c4eecd73d65..ebe6007a1c1 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/sca/ScaExecutorTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/sca/ScaExecutorTest.java
@@ -70,14 +70,14 @@ class ScaExecutorTest {
File mockManifestZip = Files.newTemporaryFile();
ScannerReportWriter mockReportWriter = mock(ScannerReportWriter.class);
when(cliCacheService.cacheCli()).thenReturn(mockCliFile);
- when(cliService.generateManifestsZip(root, mockCliFile, configuration)).thenReturn(mockManifestZip);
+ when(cliService.generateManifestsArchive(root, mockCliFile, configuration)).thenReturn(mockManifestZip);
when(reportPublisher.getWriter()).thenReturn(mockReportWriter);
logTester.setLevel(Level.DEBUG);
underTest.execute(root);
- verify(cliService).generateManifestsZip(root, mockCliFile, configuration);
+ verify(cliService).generateManifestsArchive(root, mockCliFile, configuration);
verify(mockReportWriter).writeScaFile(mockManifestZip);
assertThat(logTester.logs(Level.DEBUG)).contains("Zip ready for report: " + mockManifestZip);
assertThat(logTester.logs(Level.DEBUG)).contains("Manifest zip written to report");
@@ -87,13 +87,13 @@ class ScaExecutorTest {
void execute_whenIOException_shouldHandleException() throws IOException {
File mockCliFile = Files.newTemporaryFile();
when(cliCacheService.cacheCli()).thenReturn(mockCliFile);
- doThrow(IOException.class).when(cliService).generateManifestsZip(root, mockCliFile, configuration);
+ doThrow(IOException.class).when(cliService).generateManifestsArchive(root, mockCliFile, configuration);
logTester.setLevel(Level.INFO);
underTest.execute(root);
- verify(cliService).generateManifestsZip(root, mockCliFile, configuration);
+ verify(cliService).generateManifestsArchive(root, mockCliFile, configuration);
assertThat(logTester.logs(Level.ERROR)).contains("Error gathering manifests");
}
@@ -101,13 +101,13 @@ class ScaExecutorTest {
void execute_whenIllegalStateException_shouldHandleException() throws IOException {
File mockCliFile = Files.newTemporaryFile();
when(cliCacheService.cacheCli()).thenReturn(mockCliFile);
- doThrow(IllegalStateException.class).when(cliService).generateManifestsZip(root, mockCliFile, configuration);
+ doThrow(IllegalStateException.class).when(cliService).generateManifestsArchive(root, mockCliFile, configuration);
logTester.setLevel(Level.INFO);
underTest.execute(root);
- verify(cliService).generateManifestsZip(root, mockCliFile, configuration);
+ verify(cliService).generateManifestsArchive(root, mockCliFile, configuration);
assertThat(logTester.logs(Level.ERROR)).contains("Error gathering manifests");
}
@@ -118,7 +118,7 @@ class ScaExecutorTest {
underTest.execute(root);
- verify(cliService, never()).generateManifestsZip(root, mockCliFile, configuration);
+ verify(cliService, never()).generateManifestsArchive(root, mockCliFile, configuration);
}
@Test
@@ -150,13 +150,13 @@ class ScaExecutorTest {
File mockManifestZip = Files.newTemporaryFile();
ScannerReportWriter mockReportWriter = mock(ScannerReportWriter.class);
when(cliCacheService.cacheCli()).thenReturn(mockCliFile);
- when(cliService.generateManifestsZip(root, mockCliFile, configuration)).thenReturn(mockManifestZip);
+ when(cliService.generateManifestsArchive(root, mockCliFile, configuration)).thenReturn(mockManifestZip);
when(reportPublisher.getWriter()).thenReturn(mockReportWriter);
logTester.setLevel(Level.DEBUG);
underTest.execute(root);
- verify(cliService).generateManifestsZip(root, mockCliFile, configuration);
+ verify(cliService).generateManifestsArchive(root, mockCliFile, configuration);
verify(mockReportWriter).writeScaFile(mockManifestZip);
assertThat(logTester.logs(Level.DEBUG)).contains("Zip ready for report: " + mockManifestZip);
assertThat(logTester.logs(Level.DEBUG)).contains("Manifest zip written to report");
@@ -168,7 +168,7 @@ class ScaExecutorTest {
File mockManifestZip = Files.newTemporaryFile();
ScannerReportWriter mockReportWriter = mock(ScannerReportWriter.class);
when(cliCacheService.cacheCli()).thenReturn(mockCliFile);
- when(cliService.generateManifestsZip(root, mockCliFile, configuration)).thenReturn(mockManifestZip);
+ when(cliService.generateManifestsArchive(root, mockCliFile, configuration)).thenReturn(mockManifestZip);
when(reportPublisher.getWriter()).thenReturn(mockReportWriter);
logTester.setLevel(Level.INFO);
diff --git a/sonar-scanner-engine/src/test/resources/org/sonar/scanner/sca/echo_args.bat b/sonar-scanner-engine/src/test/resources/org/sonar/scanner/sca/echo_args.bat
index 5677cf5c437..577375b330d 100644
--- a/sonar-scanner-engine/src/test/resources/org/sonar/scanner/sca/echo_args.bat
+++ b/sonar-scanner-engine/src/test/resources/org/sonar/scanner/sca/echo_args.bat
@@ -6,7 +6,7 @@ set "POSITIONAL_ARGS="
:loop
if "%~1"=="" goto endloop
-if "%~1"=="--zip-filename" (
+if "%~1"=="--xz-filename" (
set "FILENAME=%~2"
shift
shift
diff --git a/sonar-scanner-engine/src/test/resources/org/sonar/scanner/sca/echo_args.sh b/sonar-scanner-engine/src/test/resources/org/sonar/scanner/sca/echo_args.sh
index 881be2eaac5..f7feed1f501 100755
--- a/sonar-scanner-engine/src/test/resources/org/sonar/scanner/sca/echo_args.sh
+++ b/sonar-scanner-engine/src/test/resources/org/sonar/scanner/sca/echo_args.sh
@@ -6,7 +6,7 @@ POSITIONAL_ARGS=()
while [[ $# -gt 0 ]]; do
case $1 in
- --zip-filename)
+ --xz-filename)
FILENAME="$2"
shift
shift
diff --git a/sonar-scanner-protocol/src/it/java/org/sonar/scanner/protocol/output/ScannerReportReaderIT.java b/sonar-scanner-protocol/src/it/java/org/sonar/scanner/protocol/output/ScannerReportReaderIT.java
index 384e42bb191..674c92e15fb 100644
--- a/sonar-scanner-protocol/src/it/java/org/sonar/scanner/protocol/output/ScannerReportReaderIT.java
+++ b/sonar-scanner-protocol/src/it/java/org/sonar/scanner/protocol/output/ScannerReportReaderIT.java
@@ -391,16 +391,16 @@ public class ScannerReportReaderIT {
}
@Test
- public void readDependencyFilesZip_withNoFile_returnsNull() {
- assertThat(underTest.readDependencyFilesZip()).isNull();
+ public void readDependencyFilesArchive_withNoFile_returnsNull() {
+ assertThat(underTest.readDependencyFilesArchive()).isNull();
}
@Test
- public void readDependencyFilesZip_withFile_returnsFile() throws IOException {
+ public void readDependencyFilesArchive_withFile_returnsFile() throws IOException {
ScannerReportWriter writer = new ScannerReportWriter(fileStructure);
temp.create();
- File tempFile = temp.newFile("dependency-files.zip");
+ File tempFile = temp.newFile("dependency-files.tar.xz");
byte[] expectedBytes = "hello world!".getBytes();
try (FileOutputStream fos = new FileOutputStream(tempFile)) {
fos.write(expectedBytes);
@@ -408,8 +408,8 @@ public class ScannerReportReaderIT {
writer.writeScaFile(tempFile);
- assertThat(underTest.readDependencyFilesZip()).isNotNull();
- var returnBytes = FileUtils.readFileToByteArray(underTest.readDependencyFilesZip());
+ assertThat(underTest.readDependencyFilesArchive()).isNotNull();
+ var returnBytes = FileUtils.readFileToByteArray(underTest.readDependencyFilesArchive());
assertThat(returnBytes).isEqualTo(expectedBytes);
}
}
diff --git a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/FileStructure.java b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/FileStructure.java
index fb10916aeac..ec2d8fcf660 100644
--- a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/FileStructure.java
+++ b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/FileStructure.java
@@ -114,7 +114,7 @@ public class FileStructure {
return sca;
}
- public File dependencyFilesZip() {
- return new File(scaDir(), "dependency-files.zip");
+ public File dependencyFilesArchive() {
+ return new File(scaDir(), "dependency-files.tar.xz");
}
}
diff --git a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportReader.java b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportReader.java
index 797c6ecae74..d7543f4a6d4 100644
--- a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportReader.java
+++ b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportReader.java
@@ -19,8 +19,6 @@
*/
package org.sonar.scanner.protocol.output;
-import static org.sonar.core.util.CloseableIterator.emptyCloseableIterator;
-
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -30,6 +28,8 @@ import javax.annotation.CheckForNull;
import org.sonar.core.util.CloseableIterator;
import org.sonar.core.util.Protobuf;
+import static org.sonar.core.util.CloseableIterator.emptyCloseableIterator;
+
public class ScannerReportReader {
private final FileStructure fileStructure;
@@ -218,8 +218,8 @@ public class ScannerReportReader {
return Protobuf.readStream(file, ScannerReport.AnalysisWarning.parser());
}
- public File readDependencyFilesZip() {
- File file = fileStructure.dependencyFilesZip();
+ public File readDependencyFilesArchive() {
+ File file = fileStructure.dependencyFilesArchive();
if (fileExists(file)) {
return file;
}