Skip to content

Commit 9324ae3

Browse files
JS-916 Remove logic related to SonarSec (#5872)
Co-authored-by: Karim El Ouerghemmi <karim.ouerghemmi@sonarsource.com>
1 parent ea2924d commit 9324ae3

File tree

95 files changed

+891
-1477
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+891
-1477
lines changed

.cirrus.template.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,8 @@ plugin_qa_fast_without_node_task:
377377
<<: *PLUGIN_QA_FAST_BODY
378378
env:
379379
# EslintCustomRulesTest requires Node.js in host OS
380-
MVN_TEST: '-Dtest=!EslintCustomRulesTest'
381-
IGNORE_CLASSES: '--projects !org.sonarsource.javascript:eslint-custom-rules-plugin'
380+
MVN_TEST: '-Dtest=!EslintCustomRulesTest,!EslintCustomRulesLegacyTest'
381+
IGNORE_CLASSES: '--projects !org.sonarsource.javascript:eslint-custom-rules-plugin,!org.sonarsource.javascript:eslint-custom-rules-plugin-legacy'
382382
matrix:
383383
- name: 'Fast QA without node on host Ubuntu SQ:LATEST'
384384
<<: *CONTAINER_DEFINITION

.cirrus.yml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
/*
2+
* SonarQube JavaScript Plugin
3+
* Copyright (C) 2012-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+
package com.sonar.javascript.it.plugin;
18+
19+
import static com.sonarsource.scanner.integrationtester.utility.QualityProfileLoader.loadActiveRulesFromXmlProfile;
20+
import static org.assertj.core.api.Assertions.assertThat;
21+
22+
import com.sonarsource.scanner.integrationtester.dsl.EngineVersion;
23+
import com.sonarsource.scanner.integrationtester.dsl.Log;
24+
import com.sonarsource.scanner.integrationtester.dsl.ScannerInput;
25+
import com.sonarsource.scanner.integrationtester.dsl.ScannerOutputReader;
26+
import com.sonarsource.scanner.integrationtester.dsl.SonarServerContext;
27+
import com.sonarsource.scanner.integrationtester.runner.ScannerRunner;
28+
import java.io.File;
29+
import java.nio.file.Path;
30+
import org.assertj.core.groups.Tuple;
31+
import org.junit.jupiter.api.Test;
32+
import org.sonar.plugins.javascript.JavaScriptLanguage;
33+
import org.sonar.plugins.javascript.TypeScriptLanguage;
34+
import shadow.com.sonar.orchestrator.locator.FileLocation;
35+
36+
class EslintCustomRulesLegacyTest {
37+
38+
private static final String PLUGIN_ARTIFACT_ID = "eslint-custom-rules-plugin-legacy";
39+
40+
private static final SonarServerContext SERVER_CONTEXT = SonarServerContext.builder()
41+
.withProduct(SonarServerContext.Product.SERVER)
42+
.withEngineVersion(EngineVersion.latestMasterBuild())
43+
.withPlugin(SonarScannerIntegrationHelper.getJavascriptPlugin())
44+
.withPlugin(
45+
FileLocation.byWildcardMavenFilename(
46+
new File("../plugins/" + PLUGIN_ARTIFACT_ID + "/target"),
47+
PLUGIN_ARTIFACT_ID + "-*.jar"
48+
)
49+
)
50+
.withLanguage(
51+
JavaScriptLanguage.KEY,
52+
"JAVASCRIPT",
53+
JavaScriptLanguage.FILE_SUFFIXES_KEY,
54+
JavaScriptLanguage.DEFAULT_FILE_SUFFIXES
55+
)
56+
.withLanguage(
57+
TypeScriptLanguage.KEY,
58+
"TYPESCRIPT",
59+
TypeScriptLanguage.FILE_SUFFIXES_KEY,
60+
TypeScriptLanguage.DEFAULT_FILE_SUFFIXES
61+
)
62+
.withActiveRules(
63+
loadActiveRulesFromXmlProfile(
64+
Path.of("src", "test", "resources", "profile-javascript-custom-rules-legacy.xml")
65+
)
66+
)
67+
.withActiveRules(
68+
loadActiveRulesFromXmlProfile(
69+
Path.of("src", "test", "resources", "profile-typescript-custom-rules-legacy.xml")
70+
)
71+
)
72+
.build();
73+
74+
@Test
75+
void test() {
76+
var build = ScannerInput.create("custom-rules", TestUtils.projectDirNoCopy("custom_rules"))
77+
.withVerbose()
78+
.withScmDisabled()
79+
.withSourceDirs("src")
80+
.build();
81+
var result = ScannerRunner.run(SERVER_CONTEXT, build);
82+
assertThat(result.logOutput())
83+
.filteredOn(
84+
l ->
85+
l.level().equals(Log.Level.DEBUG) &&
86+
l
87+
.message()
88+
.matches(
89+
"Deploying custom rules bundle jar:file:.*/custom-eslint-based-rules-1\\.0\\.0\\.tgz to .*"
90+
)
91+
)
92+
.hasSize(1);
93+
94+
assertThat(result.logOutput())
95+
.filteredOn(
96+
l -> l.level().equals(Log.Level.INFO) && l.message().contains("Work dir received:")
97+
)
98+
.hasSize(2);
99+
assertThat(result.logOutput())
100+
.filteredOn(l -> l.message().contains("Rule context options:"))
101+
.hasSize(2);
102+
103+
var issues = result
104+
.scannerOutputReader()
105+
.getProject()
106+
.getAllIssues()
107+
.stream()
108+
.filter(ScannerOutputReader.TextRangeIssue.class::isInstance)
109+
.map(ScannerOutputReader.TextRangeIssue.class::cast)
110+
.toList();
111+
var eslintCustomRuleIssues = issues
112+
.stream()
113+
.filter(issue -> issue.ruleKey().equals("eslint-custom-rules:sqKey"))
114+
.toList();
115+
116+
assertThat(eslintCustomRuleIssues).hasSize(2);
117+
assertThat(eslintCustomRuleIssues)
118+
.extracting(
119+
ScannerOutputReader.TextRangeIssue::ruleKey,
120+
ScannerOutputReader.TextRangeIssue::componentPath,
121+
ScannerOutputReader.TextRangeIssue::line,
122+
ScannerOutputReader.TextRangeIssue::message
123+
)
124+
.containsExactlyInAnyOrder(
125+
new Tuple("eslint-custom-rules:sqKey", "src/dir/Person.js", 21, "call"),
126+
new Tuple("eslint-custom-rules:sqKey", "src/dir/file.ts", 4, "call")
127+
);
128+
var tsEslintCustomRuleIssues = issues
129+
.stream()
130+
.filter(issue -> issue.ruleKey().equals("ts-custom-rules:tsRuleKey"))
131+
.toList();
132+
assertThat(tsEslintCustomRuleIssues)
133+
.extracting(
134+
ScannerOutputReader.TextRangeIssue::ruleKey,
135+
ScannerOutputReader.TextRangeIssue::componentPath,
136+
ScannerOutputReader.TextRangeIssue::line,
137+
ScannerOutputReader.TextRangeIssue::message
138+
)
139+
.containsExactlyInAnyOrder(
140+
new Tuple("ts-custom-rules:tsRuleKey", "src/dir/file.ts", 4, "tsrule call")
141+
);
142+
}
143+
}

its/plugin/fast-tests/src/test/java/com/sonar/javascript/it/plugin/EslintCustomRulesTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ void test() {
110110
.toList();
111111
var eslintCustomRuleIssues = issues
112112
.stream()
113-
.filter(issue -> issue.ruleKey().equals("eslint-custom-rules:sqKey"))
113+
.filter(issue -> issue.ruleKey().equals("js-custom-rules:jsRuleKey"))
114114
.toList();
115115

116-
assertThat(eslintCustomRuleIssues).hasSize(2);
116+
assertThat(eslintCustomRuleIssues).hasSize(1);
117117
assertThat(eslintCustomRuleIssues)
118118
.extracting(
119119
ScannerOutputReader.TextRangeIssue::ruleKey,
@@ -122,8 +122,7 @@ void test() {
122122
ScannerOutputReader.TextRangeIssue::message
123123
)
124124
.containsExactlyInAnyOrder(
125-
new Tuple("eslint-custom-rules:sqKey", "src/dir/Person.js", 21, "call"),
126-
new Tuple("eslint-custom-rules:sqKey", "src/dir/file.ts", 4, "call")
125+
new Tuple("js-custom-rules:jsRuleKey", "src/dir/Person.js", 21, "jsRuleKey call")
127126
);
128127
var tsEslintCustomRuleIssues = issues
129128
.stream()
@@ -137,7 +136,7 @@ void test() {
137136
ScannerOutputReader.TextRangeIssue::message
138137
)
139138
.containsExactlyInAnyOrder(
140-
new Tuple("ts-custom-rules:tsRuleKey", "src/dir/file.ts", 4, "tsrule call")
139+
new Tuple("ts-custom-rules:tsRuleKey", "src/dir/file.ts", 4, "tsRuleKey call")
141140
);
142141
}
143142
}

its/plugin/fast-tests/src/test/java/com/sonar/javascript/it/plugin/HtmlSecurityTest.java

Lines changed: 0 additions & 73 deletions
This file was deleted.

its/plugin/fast-tests/src/test/java/com/sonar/javascript/it/plugin/SonarScannerIntegrationHelper.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,6 @@ public static MavenLocation getHtmlPlugin() {
4646
return MavenLocation.of("org.sonarsource.html", "sonar-html-plugin", "LATEST_RELEASE");
4747
}
4848

49-
public static MavenLocation getSecurityPlugin() {
50-
return MavenLocation.of("com.sonarsource.security", "sonar-security-plugin", "LATEST_RELEASE");
51-
}
52-
53-
public static MavenLocation getSecurityJsFrontendPlugin() {
54-
return MavenLocation.of(
55-
"com.sonarsource.security",
56-
"sonar-security-js-frontend-plugin",
57-
"LATEST_RELEASE"
58-
);
59-
}
60-
6149
public static MavenLocation getLitsPlugin() {
6250
return MavenLocation.of("org.sonarsource.sonar-lits-plugin", "sonar-lits-plugin", LITS_VERSION);
6351
}

its/plugin/fast-tests/src/test/java/com/sonar/javascript/it/plugin/TestUtils.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,4 @@ public static void copyFile(Path sourceFile, Path targetDirectory) {
133133
throw new UncheckedIOException(e);
134134
}
135135
}
136-
137-
public static boolean isUcfgFile(Path path, BasicFileAttributes attrs) {
138-
return attrs.isRegularFile() && path.getFileName().toString().endsWith(".ucfgs");
139-
}
140136
}

its/plugin/fast-tests/src/test/java/com/sonar/javascript/it/plugin/YamlSecurityTest.java

Lines changed: 0 additions & 71 deletions
This file was deleted.

its/plugin/fast-tests/src/test/resources/html-security-profile.xml

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)