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

qualys_vmdr: Improve support for Cloud Detection and Response (CDR) workflow #11999

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

kcreddy
Copy link
Contributor

@kcreddy kcreddy commented Dec 4, 2024

Proposed commit message

Add Qualys VMDR's Asset data to Elastic's Cloud Native Vulnerability Management (CNVM) workflow.

Ref: #11673

Note

To Reviewers:
Please refer to this guide: https://docs.elastic.dev/security-solution/cloud-security/cdr/3p-dev-guide which was used for proposed changes.

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • I have verified that Kibana version constraints are current according to guidelines.
  • I have verified that any added dashboard complies with Kibana's Dashboard good practices

How to test this PR locally

  1. Pipeline Tests:
    Run: cd packages/qualys_vmdr && elastic-package build && elastic-package stack up --version=8.16.0 -d -v && eval "$(elastic-package stack shellinit)" && elastic-package test pipeline --generate -v --data-streams=asset_host_detection
    Returns success:
    --- Test results for package: qualys_vmdr - START ---
    ╭─────────────┬──────────────────────┬───────────┬──────────────────────────────────────────────────────────┬────────┬──────────────╮
    │ PACKAGE     │ DATA STREAM          │ TEST TYPE │ TEST NAME                                                │ RESULT │ TIME ELAPSED │
    ├─────────────┼──────────────────────┼───────────┼──────────────────────────────────────────────────────────┼────────┼──────────────┤
    │ qualys_vmdr │ asset_host_detection │ pipeline  │ (ingest pipeline warnings test-asset-host-detection.log) │ PASS   │ 319.428583ms │
    │ qualys_vmdr │ asset_host_detection │ pipeline  │ test-asset-host-detection.log                            │ PASS   │ 306.113459ms │
    ╰─────────────┴──────────────────────┴───────────┴──────────────────────────────────────────────────────────┴────────┴──────────────╯
    --- Test results for package: qualys_vmdr - END   ---
    Done
    
  2. System Tests:
    Run: cd packages/qualys_vmdr && elastic-package build && elastic-package stack up --version=8.16.0 -d -v && eval "$(elastic-package stack shellinit)" && elastic-package test system --generate -v --data-streams=asset_host_detection
    Returns success:
    --- Test results for package: qualys_vmdr - START ---
    ╭─────────────┬──────────────────────┬───────────┬───────────┬────────┬───────────────╮
    │ PACKAGE     │ DATA STREAM          │ TEST TYPE │ TEST NAME │ RESULT │  TIME ELAPSED │
    ├─────────────┼──────────────────────┼───────────┼───────────┼────────┼───────────────┤
    │ qualys_vmdr │ asset_host_detection │ system    │ ahd-kb    │ PASS   │ 39.780903291s │
    ╰─────────────┴──────────────────────┴───────────┴───────────┴────────┴───────────────╯
    --- Test results for package: qualys_vmdr - END   ---
    Done
    

Related issues

Screenshots

Source
Screenshot 2024-12-10 at 4 12 49 PM
Destination
Screenshot 2024-12-10 at 4 12 57 PM
Transform
Screenshot 2024-12-10 at 4 20 54 PM
Screenshot 2024-12-10 at 4 20 44 PM

@kcreddy kcreddy added the enhancement New feature or request label Dec 10, 2024
@kcreddy kcreddy self-assigned this Dec 10, 2024
@kcreddy kcreddy added the Team:Security-Service Integrations Security Service Integrations Team [elastic/security-service-integrations] label Dec 10, 2024
@kcreddy kcreddy marked this pull request as ready for review December 10, 2024 10:32
@kcreddy kcreddy requested a review from a team as a code owner December 10, 2024 10:32
@elasticmachine
Copy link

Pinging @elastic/security-service-integrations (Team:Security-Service Integrations)

@kcreddy kcreddy requested a review from a team December 10, 2024 11:09
@elasticmachine
Copy link

💚 Build Succeeded

History

cc @kcreddy

Copy link

Quality Gate failed Quality Gate failed

Failed conditions
60.6% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube

Comment on lines +18 to +20
- resource.id
- event.id
- data_stream.namespace
Copy link
Contributor Author

@kcreddy kcreddy Dec 10, 2024

Choose a reason for hiding this comment

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

This list of unique_key fields is different from the proposed guide due to the issue described in here and applying follow-up suggestion from here.

@@ -1,4 +1,9 @@
# newer versions go on top
- version: "6.0.0"
changes:
- description: Leverage Cloud Detection and Response (CDR) workflows in asset_host_detection data-stream.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- description: Leverage Cloud Detection and Response (CDR) workflows in asset_host_detection data-stream.
- description: Use Cloud Detection and Response (CDR) workflows in asset_host_detection data-stream.

?

@@ -1066,6 +1142,70 @@ processors:
tag: rename_qualys_vmdr_asset_host_detection_vulnerability_RESULTS_1
target_field: qualys_vmdr.asset_host_detection.vulnerability.results
ignore_missing: true
# The below 2 gsub processors facilitate `splitOnToken` in subsequent script processor which otherwise cannot split \n or \t.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# The below 2 gsub processors facilitate `splitOnToken` in subsequent script processor which otherwise cannot split \n or \t.
# The next two gsub processors facilitate `splitOnToken` in the subsequent script processor, which otherwise cannot split \n or \t.

Do we know that ; and | do not otherwise appear in the text?

return;
}
def level = Long.parseLong(ctx.qualys_vmdr.asset_host_detection.knowledge_base.SEVERITY_LEVEL);
if (['Potential Vulnerability', 'Vulnerability', 'Vulnerability or Potential Vulnerability'].contains(vuln_type)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this array be put in a params array to avoid allocs?

Comment on lines +791 to +801
if (level == 1){
ctx.qualys_vmdr.asset_host_detection.knowledge_base.SEVERITY_LEVEL = "Minimal";
} else if (level == 2) {
ctx.qualys_vmdr.asset_host_detection.knowledge_base.SEVERITY_LEVEL = "Medium";
} else if (level == 3) {
ctx.qualys_vmdr.asset_host_detection.knowledge_base.SEVERITY_LEVEL = "Serious";
} else if (level == 4) {
ctx.qualys_vmdr.asset_host_detection.knowledge_base.SEVERITY_LEVEL = "Critical";
} else if (level == 5) {
ctx.qualys_vmdr.asset_host_detection.knowledge_base.SEVERITY_LEVEL = "Urgent";
}
Copy link
Contributor

Choose a reason for hiding this comment

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

These are dense with a numeric index, so the assignment could be done from a params array after bounds checking. Same below.

Copy link
Contributor

Choose a reason for hiding this comment

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

Add a

  - append:
      field: tags
      value: preserve_original_event
      allow_duplicates: false

to the final on_failure.

"Authorization": ["Basic "+(state.user+":"+state.password).base64()],
}
}).do_request().as(resp, resp.StatusCode == 200 ?
resp.Body.as(xml, try(bytes(xml).decode_xml('qualys_api_2_0_ahd'), "decode_xml_error_ahd").as(ahd_body,
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we are now on v8.16.0 this can be

Suggested change
resp.Body.as(xml, try(bytes(xml).decode_xml('qualys_api_2_0_ahd'), "decode_xml_error_ahd").as(ahd_body,
resp.Body.as(xml, try(xml.decode_xml('qualys_api_2_0_ahd'), "decode_xml_error_ahd").as(ahd_body,

(body.?doc.HOST_LIST_VM_DETECTION_OUTPUT.RESPONSE.HOST_LIST.HOST.hasValue()
}
}).do_request().as(resp, resp.StatusCode == 200 ?
resp.Body.as(xml, try(bytes(xml).decode_xml('qualys_api_2_0_kb'), "decode_xml_error_kb").as(kb_body,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
resp.Body.as(xml, try(bytes(xml).decode_xml('qualys_api_2_0_kb'), "decode_xml_error_kb").as(kb_body,
resp.Body.as(xml, try(xml.decode_xml('qualys_api_2_0_kb'), "decode_xml_error_kb").as(kb_body,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Integration:qualys_vmdr Qualys VMDR Team:Security-Service Integrations Security Service Integrations Team [elastic/security-service-integrations]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants