Skip to content

Adds script to submit jobs#158

Merged
0x120102181f0a040a01181c merged 4 commits intosecureworks:masterfrom
mundruid:drx/submit-job-script
May 12, 2023
Merged

Adds script to submit jobs#158
0x120102181f0a040a01181c merged 4 commits intosecureworks:masterfrom
mundruid:drx/submit-job-script

Conversation

@mundruid
Copy link
Copy Markdown
Contributor

@mundruid mundruid commented Oct 21, 2022

  • Adds api/dalton.py as a generic Dalton API client
  • Adds api/examples/job_submission.py to give an example on how to use the job submission and other methods from the API.
  • Adds documentation on how to submit a job

Addresses #157

Comment thread examples/submit_job.py Outdated

DALTON_URL = os.getenv("DALTON_URL", "localhost")

# this file needs to include the sensor configuration in yaml format. Make sure that the files are in the proper directory.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the API to dynamically populate this if you wanted to.

To get current Suricata or Snort sensors (https://github.com/secureworks/dalton/blob/master/app/dalton.py#L2328):

DALTON_URL/dalton/controller_api/get-current-sensors/suricata
DALTON_URL/dalton/controller_api/get-current-sensors/snort

Or to get all sensors (https://github.com/secureworks/dalton/blob/master/app/dalton.py#L2361):

DALTON_URL/dalton/controller_api/get-current-sensors-json-full

Then take the the sensor_tech or tech (for all sensors JSON) value and use that to pull the YAML (https://github.com/secureworks/dalton/blob/master/app/dalton.py#L418):

DALTON_URL/dalton/controller_api/request_engine_conf?sensor=<sensor_tech

Copy link
Copy Markdown
Contributor Author

@mundruid mundruid Mar 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added three API calls in the api client:

  1. get_current_sensors implements API call to: DALTON_URL/dalton/controller_api/get-current-sensors-json-full
  2. get_sensor_tech
    DALTON_URL/dalton/controller_api/get-current-sensors/

I am using these then to create the parameters for the submit_job API call

Comment thread examples/submit_job.py Outdated
data = {
"sensor_tech": "suricata/6.0.4/suricata.yaml",
"optionProdRuleset": "prod",
"prod_ruleset": "/opt/dalton/rulesets/suricata/suricata.rules",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can dynamically pull lists of rulesets by sensor too (https://github.com/secureworks/dalton/blob/master/app/dalton.py#L213):

DALTON_URL/dalton/controller_api/get-prod-rulesets/suricata
DALTON_URL/dalton/controller_api/get-prod-rulesets/snort

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the API call: get_prod_rulesets for endpoints:
DALTON_URL/dalton/controller_api/get-prod-rulesets/

Used it to create the parameter for submit_jobs

Comment thread examples/submit_job.py Outdated

# test_job.pcap can be substituted with any target pcap name.
pcap = open('test_job.pcap', 'rb')
files = {"coverage-pcap0": ("test_job.pcap", pcap)}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, there is a (configurable) max number of pcap files that can be submitted at one time. To get that limit, call (https://github.com/secureworks/dalton/blob/master/app/dalton.py#L2367-L2374):

DALTON_URL/dalton/controller_api/get-max-pcap-files

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the call get_max_pcaps to serve the endpoint DALTON_URL/dalton/controller_api/get-max-pcap-files

@mundruid
Copy link
Copy Markdown
Contributor Author

mundruid commented Mar 1, 2023

@whartond thanks for the review. This helped a lot to improve the contribution. As I was reading your comments, I realized that it would be worth to create an API client and use all these calls in an example. So I added:

  • api/dalton.py as a generic Dalton API client
  • api/examples/job_submission.py to give an example on how to use the job submission and other methods from the API.

I think with these two additions I have addressed all your comments.

@0x120102181f0a040a01181c 0x120102181f0a040a01181c merged commit ce24507 into secureworks:master May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants