Skip to content
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

Adds script to submit jobs #158

Merged

Conversation

mundruid
Copy link
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


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
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
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

data = {
"sensor_tech": "suricata/6.0.4/suricata.yaml",
"optionProdRuleset": "prod",
"prod_ruleset": "/opt/dalton/rulesets/suricata/suricata.rules",
Copy link
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
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


# 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
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
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
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