Skip to content

Conversation

mc-sekoia
Copy link
Contributor

@mc-sekoia mc-sekoia commented Sep 3, 2025

Add leef handling to skyhigh format

Summary by Sourcery

Support LEEF format in the Skyhigh Secure Web Gateway integration by adding dedicated parsing stages, updating field mappings for parsed events, and adding test fixtures for LEEF cases

New Features:

  • Add a parse_leef stage to grok and standardize LEEF 1.0 messages to LEEF 2.0

Enhancements:

  • Refactor the ingest pipeline to use parsed_event mappings, unify field extraction and fallback logic, and extend date parsing for multiple timestamp fields
  • Overhaul ECS and McAfee field mappings to populate additional URL, network, file, and security metadata

Tests:

  • Introduce LEEF JSON fixtures for allowed and various blocked scenarios

Copy link
Contributor

sourcery-ai bot commented Sep 3, 2025

Reviewer's Guide

This PR enhances the Skyhigh Secure Web Gateway parser to support LEEF input by introducing a LEEF-specific grok stage and normalization to ECS fields, refactors timestamp parsing, overhauls ECS and McAfee-specific field mappings to use the new parsed_event structure, and adds LEEF-focused test cases.

File-Level Changes

Change Details Files
Introduce LEEF ingestion and normalization
  • Add parse_leef grok stage for LEEF 1.0
  • Add parsed_event stage to convert LEEF 1.0 to 2.0 or fallback to KV parsing
  • Modify pipeline order to run LEEF parse before KV parse
SkyhighSecurity/skyhigh_secure_web_gateway/ingest/parser.yml
Enhance date parsing with multiple timestamp sources
  • Add parse_date for devTime with UTC timezone
  • Update existing parse_date to use parsed_event.request_timestamp_epoch
  • Ensure all date parses reference parsed_event fields
SkyhighSecurity/skyhigh_secure_web_gateway/ingest/parser.yml
Overhaul ECS field mappings in set_ecs_fields
  • Replace parse_kv references with parsed_event for all ECS sets
  • Add new fields (url.domain, file.hash.md5, network.forwarded_ip, etc.)
  • Consolidate and simplify dictionary/translate actions
SkyhighSecurity/skyhigh_secure_web_gateway/ingest/parser.yml
Refactor McAfee-specific skyhighsecurity mappings and add LEEF tests
  • Update set_mcafee_fields to use parsed_event mappings and unified dictionary translations
  • Add dictionary mappings for boolean fields (dlp, rbi, av_scanned_up/down, ssl_scanned)
  • Add several LEEF-focused JSON test files
SkyhighSecurity/skyhigh_secure_web_gateway/ingest/parser.yml
SkyhighSecurity/skyhigh_secure_web_gateway/tests/leef_allowed_http.json
SkyhighSecurity/skyhigh_secure_web_gateway/tests/leef_blocked_auth_required_http.json
SkyhighSecurity/skyhigh_secure_web_gateway/tests/leef_blocked_http.json
SkyhighSecurity/skyhigh_secure_web_gateway/tests/leef_blocked_media_type.json
SkyhighSecurity/skyhigh_secure_web_gateway/tests/leef_blocked_name_mismatch_http.json
SkyhighSecurity/skyhigh_secure_web_gateway/tests/leef_blocked_url_filtering.json

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • Consider renaming the duplicated parse_date steps to unique identifiers (e.g., parse_date_devTime) to avoid conflicts and improve readability.
  • Remove the redundant empty description: '' and filter: '' fields throughout the pipeline to streamline the YAML and reduce noise.
  • Double-check that the fallback filter (parse_leef.message is not mapping) robustly routes partially matching LEEF or non-LEEF messages to kv.parse-kv so nothing slips through unparsed.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider renaming the duplicated `parse_date` steps to unique identifiers (e.g., `parse_date_devTime`) to avoid conflicts and improve readability.
- Remove the redundant empty `description: ''` and `filter: ''` fields throughout the pipeline to streamline the YAML and reduce noise.
- Double-check that the fallback filter (`parse_leef.message is not mapping`) robustly routes partially matching LEEF or non-LEEF messages to `kv.parse-kv` so nothing slips through unparsed.

## Individual Comments

### Comment 1
<location> `SkyhighSecurity/skyhigh_secure_web_gateway/ingest/parser.yml:105` </location>
<code_context>
+          event.start: '{{parse_date_mcafee.datetime}}'
+          observer.ip: '{{parsed_event.message.serverIP}}'
+          source.port: '{{parsed_event.message.srcPort}}'
+          event.action: '{{parsed_event.message.result}}'
+          event.reason: >-
+            {{parsed_event.message.block_reason or
+            parsed_event.message.blockReason}}
</code_context>

<issue_to_address>
event.action assignment may be overwritten by later dictionary translation.

Since event.action is assigned from parsed_event.message.result and then potentially modified by dictionary actions, please ensure the assignment order is clear and event.action is only set once to avoid confusion.

Suggested implementation:

```
          # Set event.action only once, combining result and dictionary translation if needed
          event.action: >-
            {% set action = parsed_event.message.result %}
            {% if action in action_dict %}
              {{ action_dict[action] }}
            {% else %}
              {{ action }}
            {% endif %}

```

- You will need to ensure that `action_dict` is defined in the template context, mapping possible `result` values to their translated actions.
- Remove any other assignments to `event.action` elsewhere in the file to avoid overwriting.
- If dictionary translation is performed elsewhere, consolidate it into this single assignment.
</issue_to_address>

### Comment 2
<location> `SkyhighSecurity/skyhigh_secure_web_gateway/ingest/parser.yml:189` </location>
<code_context>
+        filter: '{{parsed_event.message.client_ip == null}}'
+        name: set
+      - set:
+          url.full: >-
+            {{parsed_event.message.uri_scheme}}://{{parsed_event.message.requested_host}}{{parsed_event.message.requested_path}}
+          url.original: '{{parsed_event.message.requested_path}}'
+        filter: >-
</code_context>

<issue_to_address>
url.full is set in multiple places with different sources.

Assigning url.full from different sources may cause inconsistencies. Please standardize the assignment to ensure consistent values.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +189 to +190
url.full: >-
{{parsed_event.message.uri_scheme}}://{{parsed_event.message.requested_host}}{{parsed_event.message.requested_path}}
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: url.full is set in multiple places with different sources.

Assigning url.full from different sources may cause inconsistencies. Please standardize the assignment to ensure consistent values.

Corrected, bug on http.request.method and unified event.code with existing parser
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.

1 participant