You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by pr...@apache.org on 2021/08/31 03:01:27 UTC
[ranger] branch master updated: RANGER-3385: Duplicate SQL prefix
should not be allowed
This is an automated email from the ASF dual-hosted git repository.
pradeep pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ranger.git
The following commit(s) were added to refs/heads/master by this push:
new f4d18bf RANGER-3385: Duplicate SQL prefix should not be allowed
f4d18bf is described below
commit f4d18bfeb13e548252cbe0ef988f15b666e9e448
Author: Kishor Gollapalliwar <ki...@gmail.com>
AuthorDate: Sun Aug 29 15:55:42 2021 +0530
RANGER-3385: Duplicate SQL prefix should not be allowed
Signed-off-by: pradeep <pr...@apache.org>
---
security-admin/pom.xml | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/security-admin/pom.xml b/security-admin/pom.xml
index 032b79f..7ee2b22 100644
--- a/security-admin/pom.xml
+++ b/security-admin/pom.xml
@@ -862,6 +862,62 @@
</execution>
</executions>
</plugin>
+
+ <!-- duplicate SQL prefix validator plugin -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>1.4.1</version>
+ <executions>
+ <execution>
+ <id>duplicate-sql-file-prefix-validator</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <phase>validate</phase>
+ <configuration>
+ <rules>
+ <evaluateBeanshell>
+ <message>Looks like there are multiple SQL files with same version number prefix. Update prefix and build again.</message>
+ <condition>
+ List sqlFilePaths = org.codehaus.plexus.util.FileUtils.getFileNames(new File("security-admin/db"), "**/*.sql", null, false);
+ Map sqlFileMap = new HashMap();
+ Boolean noDupPrfx = true;
+
+ for (Iterator it = sqlFilePaths.iterator(); it.hasNext();) {
+ String currentSqlFilePath = it.next();
+
+ if (currentSqlFilePath.contains("patches")) {
+ String [] array = currentSqlFilePath.split("/");
+ String db = array[0];
+ String patch = array[(array.length - 1)];
+ Boolean prfxWithNums = java.util.regex.Pattern.matches("^[0-9]{3}-([a-zA-Z]+[-_]*)+.sql$", patch);
+
+ if (prfxWithNums) {
+ String sqlFile = sqlFileMap.get(db + "-" + patch.split("-")[0]);
+
+ if (sqlFile == null) {
+ sqlFileMap.put(db + "-" + patch.split("-")[0], currentSqlFilePath);
+ } else {
+ print("Multiple SQL files with combination: [DB=" + db + "] [VersionPrefix=" + patch.split("-")[0] + "] found, hence triggering build failure.");
+ print("Review prefixs for following files.");
+ print("1. " + sqlFile);
+ print("2. " + currentSqlFilePath);
+ noDupPrfx = false;
+ };
+ };
+ };
+ };
+
+ noDupPrfx
+ </condition>
+ </evaluateBeanshell>
+ </rules>
+ <fail>true</fail>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
<resources>
<resource>