-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Support include_extension and init template * Suuport ShTracer template * Add example for tracer template
- Loading branch information
Showing
17 changed files
with
193 additions
and
19 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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,9 @@ | ||
# For more details of tracer template and tracer manager | ||
# See: https://duetector.readthedocs.io/en/latest/managers/tracer.html | ||
|
||
[tracer.template] | ||
disabled = false | ||
|
||
[tracer.template.sh] | ||
# Add a pstracer to run the command "ps -aux" | ||
pstracer = { "comm" = ["ps", "-aux"], config = { "enable_cache" = false } } |
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,45 @@ | ||
import pytest | ||
|
||
from duetector.managers.tracer import ShellTracer, TracerTemplate | ||
|
||
|
||
def test_disabled_property(): | ||
tracer_template = TracerTemplate({"disabled": True}) | ||
assert tracer_template.disabled == True | ||
|
||
tracer_template = TracerTemplate({"disabled": False}) | ||
assert tracer_template.disabled == False | ||
|
||
|
||
def test_init(): | ||
tracer_template = TracerTemplate({"disabled": True}) | ||
assert tracer_template.init() == [] | ||
|
||
tracer_template = TracerTemplate( | ||
{ | ||
"disabled": False, | ||
"sh": { | ||
"tracer_name": { | ||
"comm": ["ps", "-aux"], | ||
"config": {"enable_cache": False}, | ||
} | ||
}, | ||
} | ||
) | ||
tracers = tracer_template.init() | ||
assert len(tracers) == 1 | ||
assert isinstance(tracers[0], ShellTracer) | ||
|
||
|
||
def test_get_wrap_tracer(): | ||
tracer_template = TracerTemplate() | ||
tracer = tracer_template._get_wrap_tracer( | ||
"sh", "tracer_name", {"comm": ["ps", "-aux"], "config": {"enable_cache": False}} | ||
) | ||
assert isinstance(tracer, ShellTracer) | ||
assert tracer.config._config_dict == {"disabled": False, "enable_cache": False} | ||
assert tracer.comm == ["ps", "-aux"] | ||
|
||
|
||
if __name__ == "__main__": | ||
pytest.main(["-s", "-vv", __file__]) |