PaladinCloud / CE

Paladin Cloud is an extensible, cloud security platform for developers. Join the community at https://discord.gg/xvCFD29Jj4
https://paladincloud.io/
Apache License 2.0
561 stars 51 forks source link

fix:[CORE-2050][Azure-Collector-Issue]Adding "Unauthorized" errorcodes/messages to Datadog omission List #2263

Open AnandPaladin opened 1 month ago

AnandPaladin commented 1 month ago

Description

This is related to https://paladincloud.atlassian.net/browse/CORE-2050 where vertex azure collector throwing datadog alerts due to "UnAuthorized" exception such as 401/403 error codes. These error codes should be excluded from datadog alerts because we are triggering notification for those alerts.

Problem

Some of the error codes are not in exclusion list.Detailed root causes are documented in this https://docs.google.com/spreadsheets/d/1dKZwK_bFE_4YRjyQX91vwYYdSxqSZEdVuyDeeZXxSb0/edit#gid=0

S.No | Failed Collector | Root cause | File | Omiited from Datadog | Solution -- | -- | -- | -- | -- | -- 1 | RegisteredApplicationInventoryCollector | 2024-06-12 23:42:38 [pool-3-thread-24] ERROR c.t.p.c.a.c.AzureCredentialManager - Error getting Grpah API token from Azure401---Unauthorized | getGraphApiAuthToken() method in AzureCredentialManager.java | Not ommited | Need to add ommisionList at triggerNotificationPermissionDenied() at ErrorManageUtil.java 2 | WebAppInventoryCollector | com.microsoft.azure.management.appservice.DefaultErrorResponseException: Status code 403, { "error": { "code": "AuthorizationFailed", "message": "The client '94b60d78-9ae6-4cf8-9b1c-2d17a2b1bab6' with object id '94b60d78-9ae6-4cf8-9b1c-2d17a2b1bab6' does not have authorization to perform action 'Microsoft.Web/sites/config/list/action' over scope '/subscriptions/5cccdb97-2331-4736-8a35-cba63b5c9b54/resourceGroups/CorpIT.Dev.VioletAI.USE/providers/Microsoft.Web/sites/vi-dev-violetai-botapp/config/authsettings' or the scope is invalid. If access was recently granted, please refresh your credentials." }} | WebAppInventoryCollector getAuthenticationConfig() method | Omiited from Datadog |   3 | VaultInventoryCollector | 2024-06-12 23:43:16 [pool-13-thread-13] ERROR c.t.p.a.i.c.VaultInventoryCollector - Status code 403, { "error": { "code": "Forbidden", "message": "Caller is not authorized to perform action on resource.\r\nIf role assignments, deny assignments or role definitions were changed recently, please observe propagation time.\r\nCaller: appid=15779caf-a560-4578-8be8-c531e9f5449a;oid=94b60d78-9ae6-4cf8-9b1c-2d17a2b1bab6;iss=https://sts.windows.net/dd64b6ec-0a2a-4f60-8ca1-eeaab33884d7/\r\nAction: 'Microsoft.KeyVault/vaults/keys/read'\r\nResource: '/subscriptions/f889eecb-2eaa-4c83-b9bf-341c012ecc3a/resourcegroups/corpit-test-automation-use/providers/microsoft.keyvault/vaults/corpit-test-kv-us-domain'\r\nAssignment: (not found)\r\nDenyAssignmentId: null\r\nDecisionReason: null \r\nVault: CorpIT-Test-KV-US-domain;location=eastus\r\n", "innererror": { "code": "ForbiddenByRbac" } }} | VaultInventoryCollector.java | Not ommited | Need to add ommisionList at triggerNotificationPermissionDenied() at ErrorManageUtil.java ### Solution Adding additional error codes (401/403) to omission list ## Fixes # (issue if any) ## Type of change **Please delete options that are not relevant.** - [x] Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration - [ ] Test A - [ ] Test B ## Checklist: - [x] My code follows the style guidelines of this project - [ ] My commit message/PR follows the contribution guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes ## **Other Information**: ## List any documentation updates that are needed for the Wiki ## Summary by CodeRabbit - **Bug Fixes** - Improved error handling by adding additional strings to the exception lists, including "Unauthorized", "Forbidden", and "ForbiddenByRbac", to better manage permission-denied notifications.
coderabbitai[bot] commented 1 month ago

Walkthrough

The modifications in ErrorManageUtil.java enrich the triggerNotificationPermissionDenied method by adding new exception strings ("Unauthorized", "Forbidden", and "ForbiddenByRbac") to the exceptionList. This enhancement helps in better error handling and notification when specific permission issues occur in the Azure inventory utility.

Changes

File Path Change Summary
...bile/pacbot/azure/inventory/util/ErrorManageUtil.java Updated triggerNotificationPermissionDenied() to include additional exceptions in the exceptionList and misconfiguredExceptionList lists.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ErrorManageUtil

    Note over User,ErrorManageUtil: Permission Denied Scenario

    User ->> ErrorManageUtil: triggerNotificationPermissionDenied
    ErrorManageUtil ->> ErrorManageUtil: Check exceptions (Unauthorized, Forbidden, ForbiddenByRbac)
    ErrorManageUtil -->> User: Notify Permission Denied

Poem

🐇 In the realm of Azure's might,
New exceptions come to light.
Unauthorized, Forbidden's call,
ErrorManageUtil catches them all.
Permissions clear, the path defined,
In code's embrace, solutions find. 🚀


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai generate interesting stats about this repository and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (invoked as PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud