Skip to content

Conversation

@XiaoBoAI
Copy link
Collaborator

@XiaoBoAI XiaoBoAI commented Jan 9, 2026

  • Add gitleaks for hardcoded secrets detection
  • Add detect-aws-credentials hook
  • Add .gitleaks.toml for custom rules (AI/LLM API keys)

OpenJudge Version

[The version of OpenJudge you are working on, e.g. import openjudge; print(openjudge.__version__)]

Description

[Please describe the background, purpose, changes made, and how to test this PR]

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has been formatted with pre-commit run --all-files command
  • All tests are passing
  • Docstrings are in Google style
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

- Add gitleaks for hardcoded secrets detection
- Add detect-aws-credentials hook
- Add .gitleaks.toml for custom rules (AI/LLM API keys)
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @XiaoBoAI, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly bolsters the project's security by implementing automated secret detection mechanisms. By integrating new pre-commit hooks, the system will now proactively identify and prevent the accidental inclusion of sensitive credentials and API keys, including those specific to AI/LLM services, directly into the codebase. This helps maintain a cleaner and more secure repository.

Highlights

  • Secret Detection with Gitleaks: Integrated the gitleaks pre-commit hook to automatically scan for hardcoded secrets before commits, enhancing security.
  • AWS Credential Detection: Added the detect-aws-credentials pre-commit hook to prevent accidental exposure of AWS access keys.
  • Custom Gitleaks Rules: Introduced a .gitleaks.toml configuration file with custom rules specifically designed to detect AI/LLM API keys (e.g., Dashscope, OpenAI, Anthropic, Alibaba Cloud, HuggingFace) and generic API key patterns.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces pre-commit hooks for secret detection using gitleaks and detect-aws-credentials, which is a great security enhancement. The custom gitleaks configuration is well-structured, but some of the regular expressions for key detection can be improved for better accuracy and maintainability. I've provided suggestions to make the regex patterns more specific to the key formats they are targeting, which will help reduce false positives and ensure real secrets are caught. I also recommend removing one custom rule that is less specific than the default gitleaks rule it overrides.

.gitleaks.toml Outdated
[[rules]]
id = "openai-project-key"
description = "OpenAI Project API Key"
regex = '''sk-proj-[a-zA-Z0-9_-]{80,}'''
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The regex for OpenAI Project API keys is incorrect. Project keys have a fixed length of 48 alphanumeric characters following the sk-proj- prefix, for a total of 56 characters. The current regex looks for a minimum of 80 characters and incorrectly includes _ and - as valid characters in the key.

regex = '''sk-proj-[a-zA-Z0-9]{48}'''

.gitleaks.toml Outdated
Comment on lines 55 to 59
[[rules]]
id = "anthropic-api-key"
description = "Anthropic API Key"
regex = '''sk-ant-[a-zA-Z0-9-_]{80,}'''
keywords = ["sk-ant-"]
Copy link
Contributor

Choose a reason for hiding this comment

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

high

This custom rule for Anthropic API keys overrides the default gitleaks rule with a less specific pattern. Since useDefault = true is set, it's better to remove this custom rule and rely on the more precise default rule (sk-ant-api03-[a-zA-Z0-9-_=]{95}). This will improve detection accuracy and reduce potential false positives.

.gitleaks.toml Outdated
[[rules]]
id = "alibaba-cloud-access-key"
description = "Alibaba Cloud Access Key ID"
regex = '''(?i)(?:alibaba|aliyun|acs)[-_]?(?:access)?[-_]?key[-_]?(?:id)?\s*[=:]\s*['"]?(LTAI[a-zA-Z0-9]{12,})['"]?'''
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The regex for Alibaba Cloud Access Key ID is a bit too loose. These keys have a fixed length, starting with LTAI followed by 20 alphanumeric characters. Making the regex more specific will improve accuracy.

regex = '''(?i)(?:alibaba|aliyun|acs)[-_]?(?:access)?[-_]?key[-_]?(?:id)?\s*[=:]\s*['"]?(LTAI[a-zA-Z0-9]{20})['"]?'''

.gitleaks.toml Outdated
[[rules]]
id = "huggingface-token"
description = "HuggingFace API Token"
regex = '''hf_[a-zA-Z0-9]{30,}'''
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The regex for HuggingFace API tokens can be more specific. These tokens consist of hf_ followed by 35 alphanumeric characters. A more precise regex will reduce the chance of false positives.

regex = '''hf_[a-zA-Z0-9]{35}'''

.gitleaks.toml Outdated
[[rules]]
id = "generic-api-key-assignment"
description = "Generic API Key Assignment"
regex = '''(?i)(?:api[-_]?key|apikey|secret[-_]?key|auth[-_]?token|access[-_]?token)\s*[=:]\s*['"]([a-zA-Z0-9_\-]{32,})['"]'''
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

In the character set [a-zA-Z0-9_\-], the hyphen - does not need to be escaped when it's at the end of the set. Removing the unnecessary backslash improves readability.

regex = '''(?i)(?:api[-_]?key|apikey|secret[-_]?key|auth[-_]?token|access[-_]?token)\s*[=:]\s*['"]([a-zA-Z0-9_-]{32,})['"]'''

- Remove openai-api-key, openai-project-key, anthropic-api-key rules
  (conflict with more accurate default gitleaks rules)
- Remove alibaba-cloud and huggingface rules (already in defaults)
- Keep only dashscope-api-key (Qwen specific, not in defaults)
@helloml0326 helloml0326 merged commit 582e28c into main Jan 9, 2026
2 checks passed
@XiaoBoAI XiaoBoAI deleted the feat/add-secret-detection-hooks branch January 9, 2026 07:13
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