Skip to content

Feat/backend security#40

Merged
neo7337 merged 7 commits intomainfrom
feat/backend-security
Mar 27, 2026
Merged

Feat/backend security#40
neo7337 merged 7 commits intomainfrom
feat/backend-security

Conversation

@neo7337
Copy link
Copy Markdown
Owner

@neo7337 neo7337 commented Mar 27, 2026

This pull request introduces important improvements to input validation, error handling, and context management across all code generators. It also bumps the Go version and adds a new dependency. The most significant changes are the introduction of strict validation for project and module names, propagation of context for cancellation support, and corresponding updates to tests.

Input validation and error handling:

  • Introduced ValidateProjectName and ValidateModuleName functions in gen_utils.go to enforce strict, safe naming conventions for generated projects and modules, preventing path traversal and other unsafe input. Added a custom ErrValidation error type for clear error reporting.
  • Updated all generator Generate methods (gen_simple_project.go, gen_microservice.go, gen_cli_app.go, gen_ai_agent.go) to validate Name and ModuleName at the start, defaulting to a safe name if empty, and returning errors early if validation fails. [1] [2] [3] [4]

Context propagation and cancellation:

  • Refactored all generator Generate methods to accept a context.Context parameter and check for cancellation at key points, allowing for graceful interruption of long-running operations. [1] [2] [3] [4]
  • Updated the CLI entrypoint in cmd/goini/new.go to pass cmd.Context() to the generator, ensuring context propagation from the command layer.

Dependency and compatibility updates:

  • Bumped Go version to 1.25.0 and added golang.org/x/time as a new dependency in go.mod.

Test updates:

  • Updated all relevant tests in generators_test.go to use the new Generate(context.Context, ...) signature, passing context.Background() as appropriate. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]

These changes make the generators more robust, secure, and responsive to user cancellation, while improving overall code safety and maintainability.

@neo7337 neo7337 merged commit 27b9c8d into main Mar 27, 2026
1 check passed
@neo7337 neo7337 deleted the feat/backend-security branch March 27, 2026 16:01
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.

1 participant