aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src/main/java
diff options
context:
space:
mode:
authorJacek <jacek.poreda@sonarsource.com>2022-08-08 10:55:09 +0200
committersonartech <sonartech@sonarsource.com>2022-08-09 20:03:19 +0000
commit71c6caf8e97af7015c265b2fe237fbc0df196694 (patch)
treedf529cd7caa98de8c445023cfd23bd404d22bd4c /sonar-scanner-engine/src/main/java
parent90a9791c5e3417221a269c736e3758823d8b6205 (diff)
downloadsonarqube-71c6caf8e97af7015c265b2fe237fbc0df196694.tar.gz
sonarqube-71c6caf8e97af7015c265b2fe237fbc0df196694.zip
SONAR-15915 Validate project key against forbidden phrases
Diffstat (limited to 'sonar-scanner-engine/src/main/java')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorValidator.java7
1 files changed, 7 insertions, 0 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorValidator.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorValidator.java
index 6b4f05f9d25..303391ee406 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorValidator.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectReactorValidator.java
@@ -20,7 +20,9 @@
package org.sonar.scanner.scan;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
+import java.util.Set;
import java.util.stream.Stream;
import javax.annotation.Nullable;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
@@ -102,6 +104,11 @@ public class ProjectReactorValidator {
if (!ComponentKeys.isValidProjectKey(projectDefinition.getKey())) {
validationMessages.add(format("\"%s\" is not a valid project key. %s.", projectDefinition.getKey(), ALLOWED_CHARACTERS_MESSAGE));
}
+ Set<String> forbiddenNamePhrases = Set.of(":BRANCH:", ":PULLREQUEST:");
+ if (forbiddenNamePhrases.stream().anyMatch(projectDefinition.getKey()::contains)) {
+ validationMessages.add(format("\"%s\" is not a valid project key. Project key must not contain following phrases [%s]", projectDefinition.getKey(),
+ String.join(", ", forbiddenNamePhrases)));
+ }
}
private boolean isBranchFeatureAvailable() {