-
-
Notifications
You must be signed in to change notification settings - Fork 0
Add rename script #78
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
amrabed
merged 6 commits into
main
from
sentinel-fix-makefile-injection-8048658510858943211
May 8, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
78a687c
π‘οΈ Sentinel: [CRITICAL] Fix command injection in Makefile
google-labs-jules[bot] 8d6350d
π‘οΈ Sentinel: Fix command injection in Makefile project initialization
google-labs-jules[bot] c2bcfe0
π‘οΈ Sentinel: Refactor rename script to use click and named arguments
google-labs-jules[bot] 39a2046
π‘οΈ Sentinel: Register rename script and improve gitignore
google-labs-jules[bot] ab329ba
π‘οΈ Sentinel: Require uv for project target and conditional install
google-labs-jules[bot] 04ac451
π‘οΈ Sentinel: Update click import style in rename script
google-labs-jules[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -170,3 +170,6 @@ cython_debug/ | |
|
|
||
| # PyPI configuration file | ||
| .pypirc | ||
|
|
||
| # AI agent logs | ||
| .[jJ]ules | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import os | ||
| import re | ||
| import shutil | ||
| from pathlib import Path | ||
|
|
||
| from click import ClickException, UsageError, command, echo, option | ||
|
|
||
|
|
||
| @command() | ||
| @option("--name", required=True, help="Project new name") | ||
| @option("--description", required=True, help="Project short description") | ||
| @option("--author", required=True, help="Author name") | ||
| @option("--email", required=True, help="Author email") | ||
| @option("--github", required=True, help="GitHub username") | ||
| def main(name: str, description: str, author: str, email: str, github: str): | ||
| # Validate name to prevent directory traversal or other injection | ||
| if not re.match(r"^[a-zA-Z0-9_-]+$", name): | ||
| raise UsageError( | ||
| f"Invalid project name '{name}'. Only alphanumeric characters, dashes, and underscores are allowed." | ||
| ) | ||
|
|
||
| source = name.replace("-", "_").lower() | ||
|
|
||
| echo(f"Initializing project '{name}' (source: '{source}')...") | ||
|
|
||
| # 1. Rename project directory | ||
| if os.path.isdir("project"): | ||
| shutil.move("project", source) | ||
| elif not os.path.isdir(source): | ||
| raise ClickException(f"Error: Neither 'project' nor '{source}' directory found.") | ||
|
|
||
| # 2. File modifications | ||
| replacements = [ | ||
| ("docs/reference/app.md", r"^::: project\.app", f"::: {source}.app"), | ||
| ("mkdocs.yml", r"^repo_name: .*", f"repo_name: {github}/{name}"), | ||
| ("mkdocs.yml", r"^repo_url: .*", f"repo_url: https://github.com/{github}/{name}"), | ||
| ("pyproject.toml", r"^source = \[.*\]", f'source = ["{source}"]'), | ||
| ("pyproject.toml", r'^app = "project\.app:main"', f'app = "{source}.app:main"'), | ||
| ("pyproject.toml", r'^name = ".*"', f'name = "{source}"'), | ||
| ("pyproject.toml", r'^description = ".*"', f'description = "{description}"'), | ||
| ("pyproject.toml", r"^authors = \[.*\]", f'authors = ["{author} <{email}>"]'), | ||
| ("docs/README.md", r"^# .*", f"# {description}"), | ||
| (".github/CODEOWNERS", r"@.*", f"@{github}"), | ||
| (".github/FUNDING.yml", r"^github: \[.*\]", f"github: [{github}]"), | ||
| ] | ||
|
|
||
| for filepath, pattern, replacement in replacements: | ||
| path = Path(filepath) | ||
| if not path.exists(): | ||
| echo(f"Warning: File {filepath} not found, skipping.") | ||
| continue | ||
|
|
||
| content = path.read_text() | ||
| new_content = re.sub(pattern, replacement, content, flags=re.MULTILINE) | ||
| path.write_text(new_content) | ||
| echo(f"Updated {filepath}") | ||
|
|
||
| echo("Project initialization complete.") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.