-
Notifications
You must be signed in to change notification settings - Fork 342
feat: Add Centralized FileService Functionality - BED-8307 #2794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mykeelium
wants to merge
26
commits into
main
Choose a base branch
from
mcuomo/BED-8307
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
9d767cc
wip: start abstraction
mykeelium 02f8ca8
wip: starting to refine localstore
mykeelium cfe8518
fix: refine the logic for localstore
mykeelium 1119be2
wip: cleanup storage interface
mykeelium acfc81f
fix: close directory on error for Get
mykeelium 37268b1
feat: pipe file service resolver around resources
mykeelium 540f470
feat: add get and move to FileService
mykeelium 8b4cc0b
fix: centralize ingest logic, add fileservice to datapipe
mykeelium 23f408a
fix: alter cleanup logic to handle orphaned files
mykeelium aebea94
feat: add retained file service
mykeelium d61a594
fix: remove temp prefix from ingest
mykeelium a12ec84
feat: add write from reader, as well as move between services
mykeelium acc6bc8
fix: localstore.go fix for recursive List if "" is passed
mykeelium 4d32ea0
feat: adding RuntimeDependencies and moving FileService to earlier st…
mykeelium 82b7c2a
chore: clean up typos
mykeelium d7ab5c2
test: bring existing tests inline with new FileService
mykeelium 9d4910d
chore: linting cleanup
mykeelium 6edc207
chore: pfc
mykeelium 6944b2c
chore: pfc
mykeelium 4571b73
chore: comment cleanup
mykeelium 01dd7e3
test: add localstorage tests
mykeelium 698faa6
test: add storage_test.go
mykeelium 8f8eeb6
test: add tests for new functionality
mykeelium e1a9086
chore: minor cleanup of todos and flatten files for temp
mykeelium c85404e
chore: rename LocalFileService to StorageFileService and typo fixes
mykeelium cd0604e
chore: pfc
mykeelium File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
In Go's path package, what are the return values of path.Base(".") and path.Base(".."), and are "."/".." safe as tar header names?💡 Result:
In Go's path package (and the related path/filepath package), the function path.Base returns the last element of a path [1][2][3]. For the inputs "." and "..", the return values are as follows: - path.Base(".") returns "." [3] - path.Base("..") returns ".." [3] Regarding their safety as tar header names, "." and ".." are generally considered unsafe or problematic when used as file paths within tar archives [4]. Including these as path components in a tar header can lead to directory traversal vulnerabilities during extraction [4]. If an archive contains entries with ".." in their paths, a naive extraction process might write files outside of the intended target directory [4]. Many modern tar implementations, including GNU tar, have built-in protections that may refuse to extract entries containing ".." or attempt to sanitize them to prevent such security risks [4]. Consequently, it is best practice to avoid using "." or ".." in tar header names to ensure both security and portability [5][4].
Citations:
🏁 Script executed:
Repository: SpecterOps/BloodHound
Length of output: 704
🏁 Script executed:
Repository: SpecterOps/BloodHound
Length of output: 1102
Harden tar entry sanitization for
"."/".."names.retainedArchiveNamecan still emit"."or".."entries for tar archives, which are unsafe and can lead to directory traversal vulnerabilities during extraction. The current logic on line 74–75 attempts to handle these cases butpath.Base(".")returns"."andpath.Base("..")returns"..", leaving the vulnerability unpatched.Proposed fix
func retainedArchiveName(filePath string) string { filePath = path.Clean(strings.TrimPrefix(filePath, "/")) - if filePath == "." || filePath == ".." || strings.HasPrefix(filePath, "../") { - return path.Base(filePath) + if filePath == "." || filePath == ".." || strings.HasPrefix(filePath, "../") { + baseName := path.Base(filePath) + if baseName == "." || baseName == ".." || baseName == "/" || baseName == "" { + return "retained-file" + } + return baseName } return filePath }📝 Committable suggestion
🤖 Prompt for AI Agents