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

Update Google Cloud Log parser plugin #4923

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

Conversation

roshanmaskey
Copy link
Contributor

@roshanmaskey roshanmaskey commented Nov 18, 2024

Google Cloud audit logs parser update

Description:

Updating Google Cloud audit log parser plugin (gcp_log.py) to extract attributes useful for investigation.

Some of the attributes extracted by the plugin are listed below:

  • principal_email: Email address of the user making the request.
  • permissions: IAM permissions required for GCP operation.
  • service_account_delegations: Service account delegation.
  • dcsa_emails: Default service account attached to a compute instance.
  • dcsa_scopes: OAuth scopes granted to the default service account attached to a compute instance.

Notes:

All contributions to Plaso undergo code review.
This makes sure that the code has appropriate test coverage and conforms to the
Plaso style guide.

One of the maintainers will examine your code, and may request changes. Check off the items below in
order, and then a maintainer will review your code.

Checklist:

  • Automated checks (GitHub Actions, AppVeyor) pass
  • No new new dependencies are required or l2tdevtools has been updated
  • Reviewer assigned

@roshanmaskey roshanmaskey requested a review from sydp November 19, 2024 05:12
@roshanmaskey roshanmaskey marked this pull request as ready for review November 19, 2024 05:12
plaso/parsers/jsonl_plugins/gcp_log.py Outdated Show resolved Hide resolved
plaso/parsers/jsonl_plugins/gcp_log.py Outdated Show resolved Hide resolved
plaso/parsers/jsonl_plugins/gcp_log.py Outdated Show resolved Hide resolved
plaso/parsers/jsonl_plugins/gcp_log.py Outdated Show resolved Hide resolved
plaso/parsers/jsonl_plugins/gcp_log.py Outdated Show resolved Hide resolved
plaso/parsers/jsonl_plugins/gcp_log.py Outdated Show resolved Hide resolved
plaso/parsers/jsonl_plugins/gcp_log.py Outdated Show resolved Hide resolved
plaso/parsers/jsonl_plugins/gcp_log.py Outdated Show resolved Hide resolved
@roshanmaskey roshanmaskey requested a review from sydp November 22, 2024 09:45
Copy link
Contributor

@sydp sydp left a comment

Choose a reason for hiding this comment

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

one additional comment but otherwise lgtm.

plaso/parsers/jsonl_plugins/gcp_log.py Show resolved Hide resolved
@roshanmaskey roshanmaskey changed the title Gcp log Update Google Cloud Log parser Nov 29, 2024
@roshanmaskey roshanmaskey changed the title Update Google Cloud Log parser Update Google Cloud Log parser plugin Nov 29, 2024
@roshanmaskey roshanmaskey requested review from joachimmetz and sydp and removed request for sydp November 29, 2024 09:27
@joachimmetz joachimmetz self-assigned this Dec 26, 2024
Copy link

codecov bot commented Dec 26, 2024

Codecov Report

Attention: Patch coverage is 91.53846% with 11 lines in your changes missing coverage. Please review.

Project coverage is 85.08%. Comparing base (9d4e13c) to head (a333753).

Files with missing lines Patch % Lines
plaso/parsers/jsonl_plugins/gcp_log.py 91.53% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4923      +/-   ##
==========================================
+ Coverage   85.05%   85.08%   +0.02%     
==========================================
  Files         431      431              
  Lines       38648    38765     +117     
==========================================
+ Hits        32873    32982     +109     
- Misses       5775     5783       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

plaso/parsers/jsonl_plugins/gcp_log.py Outdated Show resolved Hide resolved
plaso/parsers/jsonl_plugins/gcp_log.py Outdated Show resolved Hide resolved
plaso/parsers/jsonl_plugins/gcp_log.py Outdated Show resolved Hide resolved
"""Extracts compute.instances.insert information.

Args:
request (dict): JSON dictionary of the `protoPayload.request` field.
Copy link
Member

Choose a reason for hiding this comment

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

why the sudden argument name change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This method only processes information in the request field i.e. protoPayload.request. To add clarity, I renamed the method to _ParseComputeRequest.

plaso/parsers/jsonl_plugins/gcp_log.py Outdated Show resolved Hide resolved
"""
status = self._GetJSONValue(proto_payload, 'status')
if not status:
event_data.status_code = ''
Copy link
Member

Choose a reason for hiding this comment

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

Why an empty string and not None?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Attributes with value None are ignored by Timesketch. An empty string is assigned to ensure it appears in Timesketch, and Timesketch analyzers (in future) can utilize the field for successful operation filtering.

# `protoPayload.status.code` field.
#
# Empty `code` and `message` fields indicate the operation was successful.
status_code = str(self._GetJSONValue(status, 'code', ''))
Copy link
Member

Choose a reason for hiding this comment

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

Why the explicit call to str() ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is done to avoid type issues in OpenSearch. The value protoPayload.status.code is of type integer or empty.

request (dict): JSON dictionary of the `protoPayload.request` field.
event_data (GCPLogEventData): event data.
"""
# Source images are useful for investigation.
Copy link
Member

Choose a reason for hiding this comment

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

nit: comment add no value to explain the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to explain the variable.

@joachimmetz
Copy link
Member

@sydp were things remaining that should be changed from your perspective?

@sydp
Copy link
Contributor

sydp commented Dec 30, 2024

@sydp were things remaining that should be changed from your perspective?

Nothing further from me, thanks.

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