Valida entity_name em --example-domain contra path traversal e nomes inválidos - #33
Merged
Merged
Conversation
…inválidos ExampleDomainGenerator interpolava entity_name sem validação em caminhos de arquivo, permitindo path traversal (--example-domain '../../../../tmp/evil') e quebrando com NoMethodError ou constantes Ruby inválidas para nomes malformados (task_, _task, task__item, 1task). Adiciona validação por regex que rejeita esses casos com ArgumentError antes de qualquer escrita em disco. CLI#init também tratava --example-domain '' como valor informado (truthy em Ruby); agora string vazia é tratada como opção omitida, sem instanciar o gerador nem levantar erro. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- CLI#optional_generators excedia Metrics/AbcSize após a checagem de string vazia; extraída para o predicado example_domain_requested?. - Style/RedundantFreeze: regexp literal já é imutável, .freeze é redundante. - Style/WordArray: convertido %w[...] para array literal (um dos nomes inválidos de teste contém espaço escapado, o que o cop não aceita em %w). Confirmado localmente: bundle exec rspec (54 examples, 0 failures, 100% coverage) e bundle exec rubocop (0 offenses, exceto Layout/EndOfLine pré-existente em todo o repo ao rodar no Windows — nativo é CRLF mas .gitattributes força LF; não é regressão desta mudança). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
O pin em v1.146.0 (SHA 55283cc) usa um manifesto de versões desatualizado: o action não reconhece mais a imagem atual do runner ubuntu-latest (ubuntu-24.04) e não tem build de Ruby 3.3 registrado para ela, quebrando os 3 jobs da matrix (3.1, 3.2, 3.3) com "Unknown version" / runner detectado como self-hosted. Atualiza o pin para v1.321.0 (SHA 95ef2b0), release atual verificada via GitHub API. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Resumo
ExampleDomainGeneratorinterpolavaentity_namesem validação em caminhos de arquivo (lib/domain/#{entity_name}.rbetc.), permitindo path traversal (ex.:--example-domain '../../../../tmp/evil') e escrita fora do diretório alvo.task_,_task,task__item) quebravam comNoMethodError; nomes iniciados por dígito (1task) geravam constantes Ruby inválidas nos arquivos escritos.VALID_ENTITY_NAME) que rejeita esses casos comArgumentErrorantes de qualquer escrita em disco.CLI#inittratava--example-domain ''(string vazia) como valor informado (truthy em Ruby); agora é tratado como opção omitida — nenhum gerador instanciado, nenhum erro levantado.example_domain_requested?para manteroptional_generatorsdentro do limite deMetrics/AbcSizedo RuboCop.Test plan
spec/generators/example_domain_generator_spec.rb(8 nomes inválidos + vazio, todos esperandoArgumentError) espec/cli_spec.rb(--example-domain ''não levanta erro e não geralib/domain).bundle exec rspec— 54 examples, 0 failures, 100% line coverage (154/154).bundle exec rubocop— 0 offenses (excetoLayout/EndOfLine, pré-existente em todo o repo ao rodar no Windows: nativo é CRLF, mas.gitattributesforça LF; não é regressão desta mudança e reproduz igual namain).🤖 Generated with Claude Code