Skip to content

Commit 3530bfb

Browse files
committed
Do not descend after forbidden symlinks or access exceptions
1 parent 2738be5 commit 3530bfb

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/history/HistoryGuru.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,11 @@ private Collection<RepositoryInfo> addRepositories(File[] files,
419419
} catch (IllegalAccessException iae) {
420420
LOGGER.log(Level.WARNING, "Could not create repository for '"
421421
+ file + "', missing access rights.", iae);
422+
continue;
422423
} catch (ForbiddenSymlinkException e) {
423-
LOGGER.log(Level.WARNING, "Could not create repository for '"
424-
+ file + "', path traversal issues.", e);
424+
LOGGER.log(Level.WARNING, "Could not create repository for ''{0}'': {1}",
425+
new Object[] {file, e.getMessage()});
426+
continue;
425427
}
426428
if (repository == null) {
427429
// Not a repository, search its sub-dirs.

opengrok-indexer/src/main/java/org/opengrok/indexer/history/RepositoryFactory.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,16 @@ public static Repository getRepository(File file, boolean interactive)
123123
public static Repository getRepository(File file, boolean interactive, boolean isNested)
124124
throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException,
125125
IOException, ForbiddenSymlinkException {
126+
126127
RuntimeEnvironment env = RuntimeEnvironment.getInstance();
127-
Repository repo = null;
128+
String relFile = env.getPathRelativeToSourceRoot(file);
128129

130+
Repository repo = null;
129131
for (Repository rep : repositories) {
130132
if ((!isNested || rep.isNestable()) && rep.isRepositoryFor(file, interactive)) {
131133
repo = rep.getClass().getDeclaredConstructor().newInstance();
132134

133-
if (env.isProjectsEnabled() && env.getPathRelativeToSourceRoot(file).equals(File.separator)) {
135+
if (env.isProjectsEnabled() && relFile.equals(File.separator)) {
134136
LOGGER.log(Level.WARNING, "{0} was detected as {1} repository however with directory " +
135137
"matching source root. This is invalid because projects are enabled. Ignoring this " +
136138
"repository.",

0 commit comments

Comments
 (0)