Skip to content

Commit 04038d5

Browse files
committed
Git conf file security
1 parent 7ba197f commit 04038d5

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

git-gateway/src/main/java/com/axone_io/ignition/git/commissioning/utils/GitCommissioningUtils.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ public static void loadConfiguration() {
4646
logger.info("The configuration of the git module was interrupted because the project '" + config.getIgnitionProjectName() + "' already exist.");
4747
return;
4848
}
49+
50+
if(config.getRepoURI() == null || config.getRepoBranch() == null
51+
|| config.getIgnitionProjectName() == null || config.getIgnitionUserName() == null
52+
|| config.getUserName() == null || (config.getUserPassword() == null && config.getSshKey() == null)
53+
|| config.getUserEmail() == null){
54+
throw new RuntimeException("Incomplete git configuration file.");
55+
}
56+
4957
projectManager.createProject(config.getIgnitionProjectName(), new ProjectManifest(config.getIgnitionProjectName(), "", false, false, ""), new ArrayList());
5058

5159
Path projectDir = getProjectFolderPath(config.getIgnitionProjectName());
@@ -113,7 +121,7 @@ public static void loadConfiguration() {
113121
}
114122

115123

116-
static protected GitCommissioningConfig parseConfigLines(byte[] ignitionConf) throws Exception {
124+
static protected GitCommissioningConfig parseConfigLines(byte[] ignitionConf) {
117125
Pattern repoUriPattern = Pattern.compile("repo.uri");
118126
Pattern repoBranchPattern = Pattern.compile("repo.branch");
119127

@@ -169,6 +177,8 @@ static protected GitCommissioningConfig parseConfigLines(byte[] ignitionConf) th
169177
config.setSecretFromFilePath(Paths.get(line.split("=")[1]), true);
170178
}
171179
}
180+
} catch (ArrayIndexOutOfBoundsException e) {
181+
throw new RuntimeException("Invalid git configuration file.", e);
172182
} catch (Exception e) {
173183
logger.error("An error occurred while importing the Git configuration file.", e);
174184
throw new RuntimeException(e);

0 commit comments

Comments
 (0)