Skip to content

Commit 6396037

Browse files
committed
fix: add directory exclusion for manifest search
1 parent aea99c2 commit 6396037

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

include/plugify/config.hpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ namespace plugify {
141141
struct Security {
142142
std::unordered_set<std::string> whitelistedExtensions;
143143
std::unordered_set<std::string> blacklistedExtensions;
144+
std::unordered_set<std::filesystem::path> excludedDirs = DefaultExludedDirs;
144145

145146
bool HasWhitelist() const {
146147
return !whitelistedExtensions.empty();
@@ -149,6 +150,10 @@ namespace plugify {
149150
bool HasBlacklist() const {
150151
return !blacklistedExtensions.empty();
151152
}
153+
154+
bool HasExcluded() const {
155+
return excludedDirs != DefaultExludedDirs;
156+
}
152157
} security;
153158

154159
// Logging configuration
@@ -301,6 +306,10 @@ namespace plugify {
301306
security.blacklistedExtensions = other.security.blacklistedExtensions;
302307
securityChanged = true;
303308
}
309+
if (other.security.HasExcluded()) {
310+
security.excludedDirs = other.security.excludedDirs;
311+
securityChanged = true;
312+
}
304313
} else {
305314
// Other sources merge/append
306315
if (other.security.HasWhitelist()) {
@@ -317,6 +326,13 @@ namespace plugify {
317326
);
318327
securityChanged = true;
319328
}
329+
if (other.security.HasExcluded()) {
330+
security.excludedDirs.insert(
331+
other.security.excludedDirs.begin(),
332+
other.security.excludedDirs.end()
333+
);
334+
securityChanged = true;
335+
}
320336
}
321337

322338
if (securityChanged) {
@@ -451,5 +467,14 @@ namespace plugify {
451467

452468
return {};
453469
}
470+
471+
private:
472+
static constexpr std::unordered_set<std::filesystem::path> DefaultExludedDirs = {
473+
PLUGIFY_PATH_LITERAL("disabled"),
474+
PLUGIFY_PATH_LITERAL(".git"),
475+
PLUGIFY_PATH_LITERAL(".svn"),
476+
PLUGIFY_PATH_LITERAL("temp"),
477+
PLUGIFY_PATH_LITERAL("tmp"),
478+
};
454479
};
455480
} // namespace plugify

src/core/manager.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,9 @@ struct Manager::Impl {
295295
foundManifest = true;
296296
}
297297
} else if (entry.is_directory()) {
298-
subdirs.push_back(std::move(entry.path));
298+
if (!config.security.excludedDirs.contains(entry.path.filename())) {
299+
subdirs.push_back(std::move(entry.path));
300+
}
299301
}
300302
}
301303

0 commit comments

Comments
 (0)