Skip to content

fix: failsafe on gcp & gsuite #1513

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

Merged
merged 5 commits into from
Apr 3, 2025
Merged

fix: failsafe on gcp & gsuite #1513

merged 5 commits into from
Apr 3, 2025

Conversation

jychp
Copy link
Collaborator

@jychp jychp commented Apr 3, 2025

Summary

When calling cartography without arguments, we should have a failsafe strategy, especialy modules should be skipped when arguments/settings are missing.

This PR fix 2 errors:

  • gcp intel UnboundLocalError uncaught error
UnboundLocalError: cannot access local variable 'credentials' where it is not associated with a value
  • gsuite intel TypeError uncaught error
TypeError: expected str, bytes or os.PathLike object, not NoneType

Related issues or links

N/A

@jychp jychp requested a review from Copilot April 3, 2025 14:13
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces failsafe strategies to handle missing configurations during GSuite and GCP ingestions to prevent runtime errors.

  • For GSuite ingestion, the code now logs a warning and skips ingestion if the configuration file is missing or invalid.
  • For GCP ingestion, the credentials function is updated to appropriately return None on failure, and ingestion is skipped with a warning.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
cartography/intel/gsuite/init.py Added failsafe condition to log and skip GSuite ingestion when the config file is missing or invalid.
cartography/intel/gcp/init.py Modified get_gcp_credentials to return Optional and added a warning to skip ingestion when credentials are absent.

jychp added 2 commits April 3, 2025 16:15
Signed-off-by: Jeremy Chapeau <[email protected]>
Signed-off-by: Jeremy Chapeau <[email protected]>
@achantavy achantavy merged commit 66b1eac into master Apr 3, 2025
7 checks passed
@achantavy achantavy deleted the fix_gcp branch April 3, 2025 19:17
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.

2 participants