Skip to content

Rubocop: Layout/ModuleHashOnNewLine: Parser::Source::TreeRewriter detected clobbering #20033

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

Open
bcoles opened this issue Apr 12, 2025 · 1 comment
Labels
code quality Improving code quality

Comments

@bcoles
Copy link
Contributor

bcoles commented Apr 12, 2025

Steps to Reproduce

rubocop -d -a modules/evasion/windows/

Output

[...]

10 errors occurred:                                                                                                                                                                                                                                          
An error occurred while Layout/ModuleHashOnNewLine cop was inspecting /root/Desktop/metasploit-framework/modules/evasion/windows/applocker_evasion_install_util.rb:8:2.
An error occurred while Layout/ModuleHashOnNewLine cop was inspecting /root/Desktop/metasploit-framework/modules/evasion/windows/applocker_evasion_install_util.rb:8:2.
An error occurred while Layout/ModuleHashOnNewLine cop was inspecting /root/Desktop/metasploit-framework/modules/evasion/windows/applocker_evasion_msbuild.rb:8:2.
An error occurred while Layout/ModuleHashOnNewLine cop was inspecting /root/Desktop/metasploit-framework/modules/evasion/windows/applocker_evasion_msbuild.rb:8:2.
An error occurred while Layout/ModuleHashOnNewLine cop was inspecting /root/Desktop/metasploit-framework/modules/evasion/windows/applocker_evasion_presentationhost.rb:8:2.
An error occurred while Layout/ModuleHashOnNewLine cop was inspecting /root/Desktop/metasploit-framework/modules/evasion/windows/applocker_evasion_presentationhost.rb:8:2.
An error occurred while Layout/ModuleHashOnNewLine cop was inspecting /root/Desktop/metasploit-framework/modules/evasion/windows/applocker_evasion_regasm_regsvcs.rb:8:2.
An error occurred while Layout/ModuleHashOnNewLine cop was inspecting /root/Desktop/metasploit-framework/modules/evasion/windows/applocker_evasion_regasm_regsvcs.rb:8:2.
An error occurred while Layout/ModuleHashOnNewLine cop was inspecting /root/Desktop/metasploit-framework/modules/evasion/windows/applocker_evasion_workflow_compiler.rb:8:2.
An error occurred while Layout/ModuleHashOnNewLine cop was inspecting /root/Desktop/metasploit-framework/modules/evasion/windows/applocker_evasion_workflow_compiler.rb:8:2.
configuration from /root/Desktop/metasploit-framework/.rubocop.yml
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/rubocop/rubocop/issues

Mention the following information in the issue report:
1.67.0 (using Parser 3.3.7.1, rubocop-ast 1.38.1, analyzing as Ruby 2.7, running on ruby 3.3.7) [x86_64-linux-gnu]
Finished in 5.090512069000397 seconds

Example stacktrace:

An error occurred while Layout/ModuleHashOnNewLine cop was inspecting /root/Desktop/metasploit-framework/modules/evasion/windows/applocker_evasion_presentationhost.rb:8:2.
Parser::Source::TreeRewriter detected clobbering
/var/lib/gems/3.3.0/gems/parser-3.3.7.1/lib/parser/source/tree_rewriter.rb:427:in `trigger_policy'
/var/lib/gems/3.3.0/gems/parser-3.3.7.1/lib/parser/source/tree_rewriter.rb:414:in `enforce_policy'
/var/lib/gems/3.3.0/gems/parser-3.3.7.1/lib/parser/source/tree_rewriter/action.rb:234:in `call'
/var/lib/gems/3.3.0/gems/parser-3.3.7.1/lib/parser/source/tree_rewriter/action.rb:234:in `swallow'
/var/lib/gems/3.3.0/gems/parser-3.3.7.1/lib/parser/source/tree_rewriter/action.rb:98:in `with'
/var/lib/gems/3.3.0/gems/parser-3.3.7.1/lib/parser/source/tree_rewriter/action.rb:125:in `place_in_hierarchy'
/var/lib/gems/3.3.0/gems/parser-3.3.7.1/lib/parser/source/tree_rewriter/action.rb:107:in `do_combine'
/var/lib/gems/3.3.0/gems/parser-3.3.7.1/lib/parser/source/tree_rewriter/action.rb:118:in `place_in_hierarchy'
/var/lib/gems/3.3.0/gems/parser-3.3.7.1/lib/parser/source/tree_rewriter/action.rb:132:in `block in combine_children'
/var/lib/gems/3.3.0/gems/parser-3.3.7.1/lib/parser/source/tree_rewriter/action.rb:131:in `each'
/var/lib/gems/3.3.0/gems/parser-3.3.7.1/lib/parser/source/tree_rewriter/action.rb:131:in `inject'
/var/lib/gems/3.3.0/gems/parser-3.3.7.1/lib/parser/source/tree_rewriter/action.rb:131:in `combine_children'
/var/lib/gems/3.3.0/gems/parser-3.3.7.1/lib/parser/source/tree_rewriter/action.rb:222:in `merge'
/var/lib/gems/3.3.0/gems/parser-3.3.7.1/lib/parser/source/tree_rewriter/action.rb:105:in `do_combine'
/var/lib/gems/3.3.0/gems/parser-3.3.7.1/lib/parser/source/tree_rewriter/action.rb:31:in `combine'
/var/lib/gems/3.3.0/gems/parser-3.3.7.1/lib/parser/source/tree_rewriter.rb:143:in `merge!'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/cop/base.rb:374:in `apply_correction'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/cop/base.rb:453:in `attempt_correction'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/cop/base.rb:434:in `use_corrector'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/cop/base.rb:428:in `correct'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/cop/base.rb:210:in `add_offense'
/root/Desktop/metasploit-framework/lib/rubocop/cop/layout/module_hash_on_new_line.rb:30:in `block in on_def'
/root/Desktop/metasploit-framework/lib/rubocop/cop/layout/module_hash_on_new_line.rb:28:in `each'
/root/Desktop/metasploit-framework/lib/rubocop/cop/layout/module_hash_on_new_line.rb:28:in `on_def'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/cop/commissioner.rb:107:in `public_send'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/cop/commissioner.rb:107:in `block (2 levels) in trigger_responding_cops'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/cop/commissioner.rb:171:in `with_cop_error_handling'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/cop/commissioner.rb:106:in `block in trigger_responding_cops'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/cop/commissioner.rb:105:in `each'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/cop/commissioner.rb:105:in `trigger_responding_cops'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/cop/commissioner.rb:69:in `on_def'
/var/lib/gems/3.3.0/gems/rubocop-ast-1.38.1/lib/rubocop/ast/traversal.rb:137:in `block in on_dstr'
/var/lib/gems/3.3.0/gems/rubocop-ast-1.38.1/lib/rubocop/ast/traversal.rb:137:in `each'
/var/lib/gems/3.3.0/gems/rubocop-ast-1.38.1/lib/rubocop/ast/traversal.rb:137:in `on_dstr'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/cop/commissioner.rb:71:in `on_begin'
/var/lib/gems/3.3.0/gems/rubocop-ast-1.38.1/lib/rubocop/ast/traversal.rb:154:in `on_class'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/cop/commissioner.rb:71:in `on_class'
/var/lib/gems/3.3.0/gems/rubocop-ast-1.38.1/lib/rubocop/ast/traversal.rb:20:in `walk'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/cop/commissioner.rb:87:in `investigate'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/cop/team.rb:174:in `investigate_partial'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/cop/team.rb:101:in `investigate'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/runner.rb:349:in `block in inspect_file'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/runner.rb:348:in `each'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/runner.rb:348:in `flat_map'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/runner.rb:348:in `inspect_file'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/runner.rb:291:in `block in do_inspection_loop'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/runner.rb:325:in `block in iterate_until_no_changes'
<internal:kernel>:187:in `loop'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/runner.rb:318:in `iterate_until_no_changes'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/runner.rb:287:in `do_inspection_loop'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/runner.rb:168:in `block in file_offenses'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/runner.rb:193:in `file_offense_cache'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/runner.rb:167:in `file_offenses'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/runner.rb:158:in `process_file'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/runner.rb:139:in `block in each_inspected_file'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/runner.rb:138:in `each'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/runner.rb:138:in `reduce'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/runner.rb:138:in `each_inspected_file'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/runner.rb:124:in `inspect_files'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/runner.rb:77:in `run'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/cli/command.rb:11:in `run'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/cli/environment.rb:18:in `run'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/cli.rb:122:in `run_command'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/cli.rb:129:in `execute_runners'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/cli.rb:51:in `block in run'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/cli.rb:81:in `profile_if_needed'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/lib/rubocop/cli.rb:43:in `run'
/var/lib/gems/3.3.0/gems/rubocop-1.67.0/exe/rubocop:19:in `<top (required)>'
/usr/local/bin/rubocop:25:in `load'
/usr/local/bin/rubocop:25:in `<main>'
CScanning /root/Desktop/metasploit-framework/modules/evasion/windows/applocker_evasion_regasm_regsvcs.rb
Loading cache from /root/.cache/rubocop_cache/c7b01c4ff86e25a21d617c7a19ce49912b99de72/6d7a3b621ca1730e04accd938619e4bdab66cfb1/0602cbaaf3fddd1391344c22b0af507bfb9aea02
@bcoles
Copy link
Contributor Author

bcoles commented Apr 12, 2025

The autocorrection appears to work as intended, meaning that the error message can be ignored.

Running rubocop -a over the same file(s) a second time reveals no violations.

Printing the error message and stack trace is confusing.

@bcoles bcoles added code quality Improving code quality and removed bug labels Apr 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality Improving code quality
Projects
Status: No status
Development

No branches or pull requests

1 participant