-
Notifications
You must be signed in to change notification settings - Fork 502
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow accessor scope to be configured in remapping (#3290)
Fixed #3256
- Loading branch information
Showing
11 changed files
with
311 additions
and
150 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Parameters: | ||
RemappingTemplate: | | ||
remappings: | ||
# SSH mount from | ||
- type: mount | ||
scope: | | ||
LET X <= log(message="Evaluated Remapping") | ||
LET SSH_CONFIG <= dict(hostname='localhost:22', | ||
username='test', private_key="XXX") | ||
from: | ||
accessor: ssh | ||
on: | ||
accessor: file | ||
prefix: /remote/mnt | ||
path_type: linux | ||
LogRegex: "While parsing private key: ssh: no key found|remap: Failed to apply remapping|Unknown filesystem accessor file" | ||
|
||
Queries: | ||
- LET _ <= remap(config=RemappingTemplate) | ||
|
||
# Test that we are launching the ssh accessor | ||
- SELECT * FROM glob( | ||
globs='/*', root='/remote/mnt/foobar', accessor="file") | ||
|
||
# The above should emit some errors so check for them now. | ||
|
||
# 1. ssh: no key found shows that ssh accessor is receiving the | ||
# bogus key and trying to parse it. | ||
# 2. Failed to apply remapping - remapping failed to apply this will | ||
# wipe all accessors from the device manager. | ||
# 3. Unknown filesystem accessor file - the file accessor is no | ||
# longer available. This ensures we dont accidentally operate on | ||
# the host filesystem if the mapping is broken. | ||
- | | ||
SELECT * FROM test_read_logs() WHERE Log =~ LogRegex |
12 changes: 12 additions & 0 deletions
12
artifacts/testdata/server/testcases/remapping_ssh.out.yaml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
LET _ <= remap(config=RemappingTemplate)[]SELECT * FROM glob( globs='/*', root='/remote/mnt/foobar', accessor="file")[]SELECT * FROM test_read_logs() WHERE Log =~ LogRegex | ||
[ | ||
{ | ||
"Log": "Velociraptor: remap: ssh: While parsing private key: ssh: no key found\n" | ||
}, | ||
{ | ||
"Log": "Velociraptor: remap: Failed to apply remapping - will apply an empty remapping to block further processing\n" | ||
}, | ||
{ | ||
"Log": "Velociraptor: glob: Field root Unknown filesystem accessor file\n" | ||
} | ||
] |
This file contains 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.