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

chore(vulnerability): Address high vulnerabilities #10337

Closed
wants to merge 29 commits into from

Conversation

pinakipb2
Copy link
Contributor

@pinakipb2 pinakipb2 commented Apr 18, 2024

Checklist

  • The PR conforms to DataHub's Contributing Guideline (particularly Commit Message Format)
  • Links to related issues (if applicable)
  • Tests for the changes have been added/updated (if applicable)
  • Docs related to the changes have been added/updated (if applicable). If a new feature has been added a Usage Guide has been added for the same.
  • For any breaking change/potential downtime/deprecation/big changes an entry has been made in Updating DataHub

Summary by CodeRabbit

  • Bug Fixes

    • Improved randomness and security in test data generation by replacing Math.random() with crypto.getRandomValues() in various Cypress test files.
    • Enhanced error logging for JSON parsing and authorization events across multiple controllers for better error tracking and clarity.
    • Updated regex handling in schema translation utility for more robust field path segment extraction.
    • Simplified encryption algorithms in several components for improved security and performance.
    • Refined SSO callback logging to include protocol common name for better debugging insights.
  • Improvements

    • Added validation for repository URL hosts in Git configurations to ensure only allowed hosts are processed.
    • Improved error message consistency and clarity in authentication services.

@github-actions github-actions bot added smoke_test Contains changes related to smoke tests community-contribution PR or Issue raised by member(s) of DataHub Community labels Apr 18, 2024
@pinakipb2 pinakipb2 marked this pull request as ready for review April 18, 2024 18:53
@jjoyce0510
Copy link
Collaborator

Thanks for the contribution! We are going to be reviewing soon! Can you please update the branch?

Copy link
Contributor

coderabbitai bot commented Jul 9, 2024

Walkthrough

Overall, these changes primarily focus on improving security, logging, and precision across various components. Notable modifications include enhancing encryption algorithms, adopting secure random number generation, improving logging clarity, and refining error handling. These updates ensure better data protection, more accurate logs, and more robust error reporting while maintaining the core functionality.

Changes

File(s) Change Summary
SsoCallbackController.java Enhanced logging to show SSO protocol name.
RevokeAccessTokenResolver.java Removed tokenId from the log message for improved security.
DeleteSecretResolver.java Replaced secretUrn with inputUrn for better argument handling.
SecretUtils.java Simplified encryption by using the "AES" cipher instance.
translateFieldPathSegment.tsx Used regex instead of direct string manipulation for extracting typeName.
FieldExtractor.java Cast numArrayWildcards to an int in loop condition for better comparison logic.
git.py Added a check for allowed hosts when simplifying repo URLs.
mode.py Corrected regex pattern for proper matching of definition names.
ESSystemMetadataDAO.java, AuthServiceController.java, GraphQLController.java Improved error logging by simplifying and making it more generic.
authentication/filter/AuthenticationFilter.java Sent a generic unauthorized message for better security when an AuthenticationExpiredException is caught.
IngestDataPlatformInstancesStep.java, RollbackService.java Cast numEntities and return value of getNumDocsDeleted() to an int for precise calculations within loops.
dataset_ownership.js, ingestion_source.js, managing_secrets.js, managing_groups.js Switched to crypto.getRandomValues for generating random numbers securely.

Sequence Diagram(s)

N/A

Poem

A tiny change, a line to shift,
In code we trust, no need for rift.
Logs refined, encryption tight,
Security gained in dark of night. 🌙✨
Bugs begone, our quest renew,
CodeRabbit hops, a job well due! 🐇🔧


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
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • 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 Configuration 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 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 for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@pinakipb2
Copy link
Contributor Author

Thanks for the contribution! We are going to be reviewing soon! Can you please update the branch?

Sure, have updated the branch.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d204d56 and e61569c.

Files selected for processing (20)
  • datahub-frontend/app/controllers/SsoCallbackController.java (1 hunks)
  • datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/auth/RevokeAccessTokenResolver.java (1 hunks)
  • datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/ingest/secret/DeleteSecretResolver.java (1 hunks)
  • datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/ingest/secret/SecretUtils.java (2 hunks)
  • datahub-web-react/src/app/entity/dataset/profile/schema/utils/translateFieldPathSegment.tsx (1 hunks)
  • entity-registry/src/main/java/com/linkedin/metadata/models/extractor/FieldExtractor.java (1 hunks)
  • metadata-ingestion/src/datahub/configuration/git.py (2 hunks)
  • metadata-ingestion/src/datahub/ingestion/source/mode.py (1 hunks)
  • metadata-io/src/main/java/com/linkedin/metadata/systemmetadata/ESSystemMetadataDAO.java (1 hunks)
  • metadata-operation-context/src/main/java/io/datahubproject/metadata/services/SecretService.java (2 hunks)
  • metadata-service/auth-filter/src/main/java/com/datahub/auth/authentication/filter/AuthenticationFilter.java (1 hunks)
  • metadata-service/auth-servlet-impl/src/main/java/com/datahub/auth/authentication/AuthServiceController.java (6 hunks)
  • metadata-service/factories/src/main/java/com/linkedin/metadata/boot/steps/IngestDataPlatformInstancesStep.java (1 hunks)
  • metadata-service/graphql-servlet-impl/src/main/java/com/datahub/graphql/GraphQLController.java (1 hunks)
  • metadata-service/schema-registry-servlet/src/main/java/io/datahubproject/openapi/schema/registry/SchemaRegistryController.java (1 hunks)
  • metadata-service/services/src/main/java/com/linkedin/metadata/service/RollbackService.java (1 hunks)
  • smoke-test/tests/cypress/cypress/e2e/mutations/dataset_ownership.js (1 hunks)
  • smoke-test/tests/cypress/cypress/e2e/mutations/ingestion_source.js (1 hunks)
  • smoke-test/tests/cypress/cypress/e2e/mutations/managing_secrets.js (1 hunks)
  • smoke-test/tests/cypress/cypress/e2e/settings/managing_groups.js (1 hunks)
Files skipped from review due to trivial changes (3)
  • datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/auth/RevokeAccessTokenResolver.java
  • datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/ingest/secret/SecretUtils.java
  • metadata-io/src/main/java/com/linkedin/metadata/systemmetadata/ESSystemMetadataDAO.java
Additional comments not posted (25)
datahub-graphql-core/src/main/java/com/linkedin/datahub/graphql/resolvers/ingest/secret/DeleteSecretResolver.java (3)

26-26: Ensure consistency with variable renaming.

The variable inputUrn is more descriptive than secretUrn, which improves code readability. Verify that this change is consistently applied throughout the codebase to avoid any potential errors.


32-32: Return the renamed variable.

Ensure that the renamed variable inputUrn is correctly returned.


35-35: Update error message with renamed variable.

Ensure that the error message correctly references the renamed variable inputUrn.

datahub-web-react/src/app/entity/dataset/profile/schema/utils/translateFieldPathSegment.tsx (1)

31-31: Regex usage for extracting typeName is appropriate.

The use of regex to extract typeName from fieldPathSegment is a robust solution that ensures correct extraction even if the format changes.

smoke-test/tests/cypress/cypress/e2e/mutations/ingestion_source.js (1)

1-1: Enhanced security with crypto.getRandomValues().

Using crypto.getRandomValues() instead of Math.random() for generating random values enhances security by utilizing a cryptographically secure method.

smoke-test/tests/cypress/cypress/e2e/mutations/dataset_ownership.js (1)

1-1: Enhanced security with crypto.getRandomValues().

Using crypto.getRandomValues() instead of Math.random() for generating random values enhances security by utilizing a cryptographically secure method.

metadata-service/factories/src/main/java/com/linkedin/metadata/boot/steps/IngestDataPlatformInstancesStep.java (1)

64-64: Change the type of start to long to avoid potential issues.

Casting numEntities to an int within the while loop condition may lead to issues if numEntities exceeds the range of an int. Consider changing the type of start to long and fixing all relevant issues.

-    int start = 0;
+    long start = 0;

Likely invalid or redundant comment.

metadata-operation-context/src/main/java/io/datahubproject/metadata/services/SecretService.java (2)

53-53: Review the security and compatibility implications of changing the cipher instance.

Changing the cipher instance from "AES/ECB/PKCS5Padding" to "AES" may affect security and compatibility. Ensure that this change does not introduce vulnerabilities or compatibility issues.


75-75: Review the security and compatibility implications of changing the cipher instance.

Changing the cipher instance from "AES/ECB/PKCS5Padding" to "AES" may affect security and compatibility. Ensure that this change does not introduce vulnerabilities or compatibility issues.

smoke-test/tests/cypress/cypress/e2e/mutations/managing_secrets.js (1)

1-1: Good job enhancing security by using crypto.getRandomValues() instead of Math.random().

This change improves the security of random test ID generation.

smoke-test/tests/cypress/cypress/e2e/settings/managing_groups.js (1)

1-1: Security Enhancement Approved.

Switching from Math.random() to crypto.getRandomValues() for generating random IDs improves security.

datahub-frontend/app/controllers/SsoCallbackController.java (1)

69-70: Logging Enhancement Approved.

Adding a log statement to provide information about the SSO callback protocol is a useful enhancement.

metadata-ingestion/src/datahub/configuration/git.py (2)

3-3: URL Parsing Enhancement Approved.

Adding urlparse to parse and validate the repository URL enhances security and robustness.


43-48: Validation Enhancement Approved.

Validating the repository host against a list of allowed hosts improves security.

metadata-service/graphql-servlet-impl/src/main/java/com/datahub/graphql/GraphQLController.java (1)

78-78: Logging Enhancement Approved.

Refining the error logging to include the exception when JSON parsing fails is a useful enhancement.

metadata-service/services/src/main/java/com/linkedin/metadata/service/RollbackService.java (1)

176-176: Ensure the conversion to int is necessary and safe.

The conversion of getNumDocsDeleted() to an int might be necessary due to downstream requirements, but ensure that the original value is within the range of int to avoid potential overflow issues.

metadata-service/auth-filter/src/main/java/com/datahub/auth/authentication/filter/AuthenticationFilter.java (1)

95-95: LGTM! Ensure consistent error handling.

The change to send a generic error message for unauthorized actions is appropriate. Ensure that similar error handling is applied consistently across the codebase.

metadata-service/schema-registry-servlet/src/main/java/io/datahubproject/openapi/schema/registry/SchemaRegistryController.java (1)

310-314: LGTM! Validate topic names to avoid log injection.

The changes to validate topic names and log errors accordingly are appropriate. This helps avoid log injection vulnerabilities.

metadata-service/auth-servlet-impl/src/main/java/com/datahub/auth/authentication/AuthServiceController.java (6)

126-126: LGTM! Proper error logging when parsing JSON.

The change to log an error when parsing JSON while attempting to generate a session token is appropriate.


196-196: LGTM! Proper error logging when parsing JSON.

The change to log an error when parsing JSON while attempting to create a native user is appropriate.


241-241: LGTM! Proper error logging for invalid invite token.

The change to log an error when an invalid invite token is detected is appropriate.


285-285: LGTM! Proper error logging when parsing JSON.

The change to log an error when parsing JSON while attempting to reset native user credentials is appropriate.


343-343: LGTM! Proper error logging when parsing JSON.

The change to log an error when parsing JSON while attempting to verify native user password is appropriate.


389-389: LGTM! Proper error logging when parsing JSON.

The change to log an error when parsing JSON while attempting to track analytics event is appropriate.

metadata-ingestion/src/datahub/ingestion/source/mode.py (1)

Line range hint 744-749:
Verify the correctness of the regex pattern and its usage.

The regular expression pattern @[a-zA-Z]+ is used to match definition names. Ensure that this pattern correctly matches all intended cases.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e61569c and a92d1fa.

Files selected for processing (1)
  • entity-registry/src/main/java/com/linkedin/metadata/models/extractor/FieldExtractor.java (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • entity-registry/src/main/java/com/linkedin/metadata/models/extractor/FieldExtractor.java

@pinakipb2 pinakipb2 closed this Aug 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-contribution PR or Issue raised by member(s) of DataHub Community smoke_test Contains changes related to smoke tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants