Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
b11d3ce
Clean up RuboCop config
joshuay03 Nov 15, 2025
2ecca88
rubocop --only Layout/EmptyLineAfterGuardClause -a
joshuay03 Nov 15, 2025
d1a4688
be rubocop --only Style/StringLiterals -a
joshuay03 Nov 15, 2025
bff2a70
rubocop --only Layout/SpaceInsideHashLiteralBraces -a
joshuay03 Nov 15, 2025
f4a1202
rubocop --only Layout/EmptyLineBetweenDefs -a
joshuay03 Nov 15, 2025
e91ff47
rubocop --only Layout/EmptyLines -a
joshuay03 Nov 15, 2025
fc1d4a7
rubocop --only Layout/IndentationWidth -a
joshuay03 Nov 15, 2025
8ba21fb
rubocop --only Layout/SpaceInsideParens -a
joshuay03 Nov 15, 2025
c400246
rubocop --only Layout/IndentationConsistency -a
joshuay03 Nov 15, 2025
ed1da56
rubocop --only Layout/CommentIndentation -a
joshuay03 Nov 15, 2025
ffe7976
rubocop --only Style/HashSyntax -a
joshuay03 Nov 15, 2025
0021223
Disable Style/WordArray cop
joshuay03 Nov 15, 2025
70fbf60
rubocop --only Layout/EmptyLinesAroundBlockBody -a
joshuay03 Nov 15, 2025
62fef85
Disable Style/RescueStandardError cop
joshuay03 Nov 15, 2025
16eef0c
rubocop --only Style/RegexpLiteral -a
joshuay03 Nov 15, 2025
ba1b971
rubocop --only Layout/TrailingWhitespace -a
joshuay03 Nov 15, 2025
54b6216
rubocop --only Layout/EmptyLinesAroundAttributeAccessor -a
joshuay03 Nov 15, 2025
3288e92
rubocop --only Style/StringConcatenation -A
joshuay03 Nov 15, 2025
705b5c2
rubocop --only Layout/RescueEnsureAlignment -a
joshuay03 Nov 15, 2025
f4de42e
rubocop --only Layout/TrailingEmptyLines -a
joshuay03 Nov 15, 2025
765f4d4
rubocop --only Layout/EmptyLinesAroundExceptionHandlingKeywords -a
joshuay03 Nov 15, 2025
5e5dc3e
rubocop --only Style/RedundantReturn -a
joshuay03 Nov 15, 2025
ecc9664
rubocop --only Style/FetchEnvVar -a
joshuay03 Nov 15, 2025
791c430
rubocop --only Style/DefWithParentheses -a
joshuay03 Nov 15, 2025
c2166a9
Exclude spec/**/* from cops
joshuay03 Nov 15, 2025
e760829
rubocop --only Layout/LineEndStringConcatenationIndentation -a
joshuay03 Nov 15, 2025
c56cd50
Disable Style/GuardClause cop
joshuay03 Nov 15, 2025
26ad668
rubocop --only Layout/EmptyLinesAroundClassBody -a
joshuay03 Nov 15, 2025
e2849bd
rubocop --only Layout/EmptyLinesAroundModuleBody -a
joshuay03 Nov 15, 2025
b258d77
rubocop --only Lint/RedundantStringCoercion -a
joshuay03 Nov 15, 2025
b9e798e
Disable Bundler/OrderedGems cop
joshuay03 Nov 15, 2025
a3e15c6
Disable Style/IfInsideElse cop
joshuay03 Nov 15, 2025
6abd66f
rubocop --only Layout/MultilineOperationIndentation -a
joshuay03 Nov 15, 2025
702cd69
rubocop --only Style/SuperArguments -a
joshuay03 Nov 15, 2025
5832b8e
rubocop --only Layout/EmptyLinesAfterModuleInclusion -a
joshuay03 Nov 15, 2025
3ab7c25
rubocop --only Style/ConditionalAssignment -a
joshuay03 Nov 15, 2025
d1c36a4
rubocop --only Style/Not -a
joshuay03 Nov 15, 2025
3b7ea2d
rubocop --only Style/RedundantRegexpArgument -a
joshuay03 Nov 15, 2025
6f2659a
rubocop --only Layout/EmptyLinesAroundMethodBody -a
joshuay03 Nov 15, 2025
dedb90e
rubocop --only Layout/HeredocIndentation -a
joshuay03 Nov 15, 2025
876aa29
rubocop --only Style/ParenthesesAroundCondition -a
joshuay03 Nov 15, 2025
d97c9a4
rubocop --only Layout/SpaceAfterSemicolon -a
joshuay03 Nov 15, 2025
9755f84
rubocop --only Lint/UnusedMethodArgument -a
joshuay03 Nov 15, 2025
b81c736
rubocop --only Layout/SpaceInsideBlockBraces -a
joshuay03 Nov 15, 2025
d925777
rubocop --only Style/RedundantParentheses -a
joshuay03 Nov 15, 2025
cdc8621
Disable Style/CommentAnnotation cop
joshuay03 Nov 15, 2025
5358746
rubocop --only Style/MultilineIfModifier -a
joshuay03 Nov 15, 2025
b31d0d9
rubocop --only Style/Semicolon -a
joshuay03 Nov 15, 2025
d395e85
rubocop --only Style/ColonMethodCall -a
joshuay03 Nov 15, 2025
cf8fb23
rubocop --only Layout/FirstHashElementIndentation -a
joshuay03 Nov 15, 2025
cdb127c
rubocop --only Style/Dir -a
joshuay03 Nov 15, 2025
4562a19
rubocop --only Layout/EmptyLines -a
joshuay03 Nov 15, 2025
966725e
rubocop --only Lint/ParenthesesAsGroupedExpression -a
joshuay03 Nov 15, 2025
f00965f
rubocop --only Style/MultilineIfModifier -a
joshuay03 Nov 15, 2025
22cbe7c
Disable Style/IfUnlessModifier cop
joshuay03 Nov 15, 2025
3105e11
rubocop --only Lint/UselessAssignment -a
joshuay03 Nov 15, 2025
76fe850
Disable Layout/LineLength cop
joshuay03 Nov 15, 2025
a1ee494
rubocop --only Style/TrailingCommaInArrayLiteral -a
joshuay03 Nov 15, 2025
a6b9861
rubocop --only Style/MethodCallWithoutArgsParentheses -a
joshuay03 Nov 15, 2025
a94dfd5
rubocop --only Layout/LeadingCommentSpace -a
joshuay03 Nov 15, 2025
0c3574f
rubocop --only Layout/ExtraSpacing -a
joshuay03 Nov 15, 2025
843f610
be rubocop --only Style/RedundantStringEscape -a
joshuay03 Nov 15, 2025
c7ee2d0
Disable Style/BlockDelimiters cop
joshuay03 Nov 15, 2025
d320573
rubocop --only Layout/IndentationStyle -a
joshuay03 Nov 15, 2025
f6dabb3
rubocop --only Layout/MultilineMethodCallIndentation -a
joshuay03 Nov 15, 2025
e8ddc9f
rubocop --only Layout/IndentationConsistency -a
joshuay03 Nov 15, 2025
2cf4bb5
rubocop --only Layout/HashAlignment -a
joshuay03 Nov 15, 2025
863676a
rubocop --only Layout/EndAlignment -a
joshuay03 Nov 15, 2025
579614b
rubocop --only Layout/IndentationWidth -a
joshuay03 Nov 15, 2025
b020de9
rubocop --only Layout/SpaceAfterColon -a
joshuay03 Nov 15, 2025
0424d9c
rubocop --only Style/RedundantPercentQ -a
joshuay03 Nov 15, 2025
5ccc33c
rubocop --only Layout/SpaceInsideArrayLiteralBrackets -a
joshuay03 Nov 15, 2025
1ef8647
rubocop --only Layout/SpaceAfterComma -a
joshuay03 Nov 15, 2025
b6028c9
rubocop --only Lint/Void -a
joshuay03 Nov 15, 2025
cb6392d
rubocop --only Layout/LineContinuationLeadingSpace -a
joshuay03 Nov 15, 2025
23a78cb
rubocop --only Style/TrailingUnderscoreVariable -a
joshuay03 Nov 15, 2025
79fa58e
rubocop --only Layout/ElseAlignment -a
joshuay03 Nov 15, 2025
8bdc14e
rubocop --only Layout/IndentationWidth -a
joshuay03 Nov 15, 2025
915369f
rubocop --only Layout/IndentationConsistency -a
joshuay03 Nov 15, 2025
23bdc2a
rubocop --only Style/RedundantSelf -a
joshuay03 Nov 15, 2025
4586e94
rubocop --only Style/PerlBackrefs -a
joshuay03 Nov 15, 2025
48bef7b
rubocop --only Style/YAMLFileRead -a
joshuay03 Nov 15, 2025
9769be2
Address CodeQL feedback
joshuay03 Nov 16, 2025
6601d0c
Run RuboCop in CI
joshuay03 Nov 16, 2025
66531f0
Exclude vendor/**/* from RuboCop
joshuay03 Nov 16, 2025
c869540
Merge branch 'master' into configure-rubocop
zinduolis Dec 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: "RuboCop"

on:
pull_request:
branches: [master]

jobs:
rubocop:
name: "RuboCop Analysis"
runs-on: ubuntu-latest
steps:
- name: "Checkout the repository"
uses: actions/checkout@v4
Copy link
Contributor

@zinduolis zinduolis Nov 16, 2025

Choose a reason for hiding this comment

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

Version 5 has been recently released. Can we please use it instead of 4 is possible?

https://github.com/actions/checkout

with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 2

- name: "Update and Install Dependencies"
run: |
sudo apt update
sudo apt install libcurl4 libcurl4-openssl-dev

- name: "Setting up Ruby"
uses: ruby/setup-ruby@v1
with:
bundler-cache: true

- name: "Configure Bundle testing and install gems"
run: |
bundle config unset --local without
bundle config set --local with 'development'
bundle install

- name: "Run RuboCop"
run: |
bundle exec rubocop --display-only-safe-correctable
46 changes: 24 additions & 22 deletions .github/workflows/github_actions.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,57 @@
name: 'BrowserStack Test'
name: "BrowserStack Test"

on:
pull_request_target:
branches: [ master ]
jobs:
branches: [master]

jobs:
ubuntu-job:
name: 'BrowserStack Test on Ubuntu'
runs-on: ubuntu-latest # Can be self-hosted runner also
name: "BrowserStack Test on Ubuntu"
runs-on: ubuntu-latest # Can be self-hosted runner also
environment:
name: Integrate Pull Request
env:
env:
GITACTIONS: true
steps:

- name: 'BrowserStack Env Setup' # Invokes the setup-env action
- name: "BrowserStack Env Setup" # Invokes the setup-env action
uses: browserstack/github-actions/setup-env@master
with:
username: ${{ secrets.BROWSERSTACK_USERNAME }}
username: ${{ secrets.BROWSERSTACK_USERNAME }}
access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}

- name: 'BrowserStack Local Tunnel Setup' # Invokes the setup-local action
- name: "BrowserStack Local Tunnel Setup" # Invokes the setup-local action
uses: browserstack/github-actions/setup-local@master
with:
local-testing: start
local-identifier: random

- name: 'Checkout the repository'
- name: "Checkout the repository"
uses: actions/checkout@v4
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we please use version 5 if possible?

with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 2

- name: 'Setting up Ruby'
uses: ruby/setup-ruby@v1
# Ruby version is defined in .ruby-version file

- name: 'Update and Install Dependencies'
- name: "Update and Install Dependencies"
run: |
sudo apt update
sudo apt install libcurl4 libcurl4-openssl-dev
- name: 'Configure Bundle testing and install gems'

- name: "Setting up Ruby"
uses: ruby/setup-ruby@v1
with:
bundler-cache: true

- name: "Configure Bundle testing and install gems"
run: |
bundle config unset --local without
bundle config set --local with 'test' 'development'
bundle config set --local with 'test'
bundle install
- name: 'Run BrowserStack simple verification'

- name: "Run BrowserStack simple verification"
run: |
bundle exec rake browserstack --trace

- name: 'BrowserStackLocal Stop' # Terminating the BrowserStackLocal tunnel connection
- name: "BrowserStackLocal Stop" # Terminating the BrowserStackLocal tunnel connection
uses: browserstack/github-actions/setup-local@master
with:
local-testing: stop
local-testing: stop
45 changes: 35 additions & 10 deletions .rubocop.yml
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the purpose of loosening the conditions?

Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
AllCops:
Exclude:
- 'test/**/*'
- 'tmp/**/*'
- 'tools/**/*'
- 'doc/**/*'
TargetRubyVersion: <%= File.read(".ruby-version").strip[/^(\d+\.\d+)/, 1] || raise("Ruby version not found") %>

NewCops: enable

Exclude:
- "vendor/**/*"
- "tools/**/*"
- "spec/**/*"
- "test/**/*"

Bundler/OrderedGems:
Enabled: false

Layout/LineLength:
Enabled: true
Max: 180
Enabled: false

Metrics/AbcSize:
Enabled: false
Expand All @@ -20,6 +24,9 @@ Metrics/BlockLength:
Metrics/ClassLength:
Enabled: false

Metrics/CyclomaticComplexity:
Enabled: false

Metrics/MethodLength:
Enabled: false

Expand All @@ -29,14 +36,32 @@ Metrics/ModuleLength:
Metrics/PerceivedComplexity:
Enabled: false

Metrics/CyclomaticComplexity:
Naming/ClassAndModuleCamelCase:
Enabled: false

Naming/ClassAndModuleCamelCase:
Style/BlockDelimiters:
Enabled: false

Style/FrozenStringLiteralComment:
Style/CommentAnnotation:
Enabled: false

Style/Documentation:
Enabled: false

Style/GuardClause:
Enabled: false

Style/IfInsideElse:
Enabled: false

Style/IfUnlessModifier:
Enabled: false

Style/RescueStandardError:
Enabled: false

Style/WordArray:
Enabled: false

Style/FrozenStringLiteralComment:
Enabled: false
11 changes: 7 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# See the file 'doc/COPYING' for copying permission
#

source 'https://rubygems.org'

gem 'net-smtp', require: false
gem 'json'

Expand All @@ -17,14 +19,13 @@ gem 'uglifier', '~> 4.2'
gem 'mime-types', '~> 3.7'
gem 'execjs', '~> 2.10'
gem 'ansi', '~> 1.5'
gem 'term-ansicolor', :require => 'term/ansicolor'
gem 'term-ansicolor', require: 'term/ansicolor'
gem 'rubyzip', '~> 3.2'
gem 'espeak-ruby', '~> 1.1.0' # Text-to-Voice
gem 'rake', '~> 13.3'
gem 'activerecord', '~> 8.1'
gem 'otr-activerecord', '~> 2.6.0'
gem 'sqlite3', '~> 2.8'
gem 'rubocop', '~> 1.81.7', require: false

# Geolocation support
group :geoip do
Expand Down Expand Up @@ -59,6 +60,10 @@ group :ext_qrcode do
gem 'qr4r', '~> 0.6.1'
end

group :development do
gem 'rubocop', '~> 1.81.7', require: false
end

# For running unit tests
group :test do
gem 'test-unit-full', '~> 0.0.5'
Expand Down Expand Up @@ -86,5 +91,3 @@ group :test do
# sudo port install libxml2 libxslt
gem 'capybara', '~> 3.40'
end

source 'https://rubygems.org'
60 changes: 30 additions & 30 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
require 'rspec/core/rake_task'

task :default => ["short"]
task default: ['short']

RSpec::Core::RakeTask.new(:short) do |task|
task.rspec_opts = ['--tag ~run_on_browserstack', '--tag ~run_on_long_tests']
Expand All @@ -27,7 +27,7 @@ RSpec::Core::RakeTask.new(:browserstack) do |task|
end

RSpec::Core::RakeTask.new(:bs) do |task|
configs = Dir["spec/support/browserstack/**/*.yml"]
configs = Dir['spec/support/browserstack/**/*.yml']
configs.each do |config|
config = config.split('spec/support/browserstack')[1]
ENV['CONFIG_FILE'] = config
Expand All @@ -48,21 +48,21 @@ namespace :ssl do
puts 'Certificate already exists. Replace? [Y/n]'
confirm = STDIN.getch.chomp
unless confirm.eql?('') || confirm.downcase.eql?('y')
puts "Aborted"
puts 'Aborted'
exit 1
end
end
Rake::Task['ssl:replace'].invoke
end

desc 'Re-generate SSL certificate'
task :replace do
if File.file?('/usr/local/bin/openssl')
path = '/usr/local/bin/openssl'
elsif File.file?('/usr/bin/openssl')
path = '/usr/bin/openssl'
else
puts "[-] Error: could not find openssl"
puts '[-] Error: could not find openssl'
exit 1
end
IO.popen([path, 'req', '-new', '-newkey', 'rsa:4096', '-sha256', '-x509', '-days', '3650', '-nodes', '-out', 'beef_cert.pem', '-keyout', 'beef_key.pem', '-subj', '/CN=localhost'], 'r+').read.to_s
Expand All @@ -88,8 +88,8 @@ namespace :rdoc do
rd.rdoc_dir = 'doc/rdocs'
rd.main = 'README.mkd'
rd.rdoc_files.include('core/**/*\.rb')
#'extensions/**/*\.rb'
#'modules/**/*\.rb'
# 'extensions/**/*\.rb'
# 'modules/**/*\.rb'
rd.options << '--line-numbers'
rd.options << '--all'
end
Expand All @@ -98,15 +98,15 @@ end
################################
# X11 set up

@xserver_process_id = nil;
@xserver_process_id = nil

task :xserver_start do
printf "Starting X11 Server (wait 10 seconds)..."
@xserver_process_id = IO.popen("/usr/bin/Xvfb :0 -screen 0 1024x768x24 2> /dev/null", "w+")
printf 'Starting X11 Server (wait 10 seconds)...'
@xserver_process_id = IO.popen('/usr/bin/Xvfb :0 -screen 0 1024x768x24 2> /dev/null', 'w+')
delays = [2, 2, 1, 1, 1, 0.5, 0.5, 0.5, 0.3, 0.2, 0.1, 0.1, 0.1, 0.05, 0.05]
delays.each do |i| # delay for 10 seconds
printf '.'
sleep (i) # increase the . display rate
sleep(i) # increase the . display rate
end
puts '.'
end
Expand All @@ -119,16 +119,16 @@ end
################################
# BeEF environment set up

@beef_process_id = nil;
@beef_config_file = 'tmp/rk_beef_conf.yaml';
@beef_process_id = nil
@beef_config_file = 'tmp/rk_beef_conf.yaml'

task :beef_start => 'beef' do
task beef_start: 'beef' do
# read environment param for creds or use bad_fred
test_user = ENV['TEST_BEEF_USER'] || 'bad_fred'
test_pass = ENV['TEST_BEEF_PASS'] || 'bad_fred_no_access'

# write a rake config file for beef
config = YAML.safe_load(File.read('./config.yaml'))
config = YAML.safe_load_file('./config.yaml')
config['beef']['credentials']['user'] = test_user
config['beef']['credentials']['passwd'] = test_pass
Dir.mkdir('tmp') unless Dir.exist?('tmp')
Expand All @@ -140,12 +140,12 @@ task :beef_start => 'beef' do
config = nil
puts "Using config file: #{@beef_config_file}\n"

printf "Starting BeEF (wait a few seconds)..."
@beef_process_id = IO.popen("ruby ./beef -c #{@beef_config_file} -x 2> /dev/null", "w+")
printf 'Starting BeEF (wait a few seconds)...'
@beef_process_id = IO.popen("ruby ./beef -c #{@beef_config_file} -x 2> /dev/null", 'w+')
delays = [5, 5, 5, 4, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1]
delays.each do |i| # delay for a few seconds
printf '.'
sleep (i)
sleep(i)
end
puts ".\n\n"
end
Expand All @@ -165,41 +165,41 @@ end
################################
# MSF environment set up

@msf_process_id = nil;
@msf_process_id = nil

task :msf_start => '/tmp/msf-test/msfconsole' do
printf "Starting MSF (wait 45 seconds)..."
@msf_process_id = IO.popen("/tmp/msf-test/msfconsole -r test/thirdparty/msf/unit/BeEF.rc 2> /dev/null", "w+")
task msf_start: '/tmp/msf-test/msfconsole' do
printf 'Starting MSF (wait 45 seconds)...'
@msf_process_id = IO.popen('/tmp/msf-test/msfconsole -r test/thirdparty/msf/unit/BeEF.rc 2> /dev/null', 'w+')
delays = [10, 7, 6, 5, 4, 3, 2, 2, 1, 1, 1, 0.5, 0.5, 0.5, 0.3, 0.2, 0.1, 0.1, 0.1, 0.05, 0.05]
delays.each do |i| # delay for 45 seconds
printf '.'
sleep (i) # increase the . display rate
sleep(i) # increase the . display rate
end
puts '.'
end

task :msf_stop do
puts "\nShutting down MSF...\n"
@msf_process_id.puts "quit"
@msf_process_id.puts 'quit'
end

task :msf_install => '/tmp/msf-test/msfconsole' do
task msf_install: '/tmp/msf-test/msfconsole' do
# Handled by the 'test/msf-test/msfconsole' task.
end

task :msf_update => '/tmp/msf-test/msfconsole' do
sh "cd /tmp/msf-test;git pull"
task msf_update: '/tmp/msf-test/msfconsole' do
sh 'cd /tmp/msf-test;git pull'
end

file '/tmp/msf-test/msfconsole' do
puts "Installing MSF"
sh "cd test;git clone https://github.com/rapid7/metasploit-framework.git /tmp/msf-test"
puts 'Installing MSF'
sh 'cd test;git clone https://github.com/rapid7/metasploit-framework.git /tmp/msf-test'
end

################################
# ActiveRecord
namespace :db do
task :environment do
require_relative "beef"
require_relative 'beef'
end
end
Loading
Loading