Test coverage improvements - Core#3503
Conversation
| if IO.popen(%w[which espeak], 'r').read.to_s.eql?('') | ||
| print_error('[Text to Voice] eSpeak is not in $PATH (brew install espeak on macOS, apt-get install espeak on Linux)') | ||
| return | ||
| end | ||
| if IO.popen(%w[which lame], 'r').read.to_s.eql?('') | ||
| print_error('[Text to Voice] Lame is not in $PATH (apt-get install lame)') | ||
| print_error('[Text to Voice] Lame is not in $PATH (brew install lame on macOS, apt-get install lame on Linux)') | ||
| return | ||
| end | ||
| if IO.popen(%w[which espeak], 'r').read.to_s.eql?('') | ||
| print_error('[Text to Voice] eSpeak is not in $PATH (apt-get install espeak)') | ||
|
|
||
| # Load espeak gem (only if binaries are available) | ||
| begin | ||
| require 'espeak' | ||
| include ESpeak | ||
| rescue LoadError, StandardError => e | ||
| print_error("[Text to Voice] Failed to load espeak gem: #{e.message}") |
There was a problem hiding this comment.
Additional logging to help with new installs. This caught me out.
| RSpec.describe BeEF::Filters do | ||
| describe '.is_non_empty_string?' do | ||
| it 'nil' do | ||
| expect(BeEF::Filters.is_non_empty_string?(nil)).to be(false) | ||
| end |
There was a problem hiding this comment.
Replaces the old filters_spec.rb that was missing methods and combined different files. This is more specific
|
Hey @jake-the-dev , Are you still working on this PR or it's ready for review? I can see its status is Draft. Thanks |
Hi @zinduolis , I initially intended to continue this until core was sufficiently covered. However on Friday Wade had asked for this to be merged. I don't have the permissions so i assumed he was going to merge - or maybe thats something he left with you? To clarify - I will remove draft and any further iterations to core tests will be in another pr. Feel free to review if you wish, no functional code should be changed so it should all just be assertions on existing logic. |
|
Thanks, @jake-the-dev , just click Ready for review and I will review it and will let you know when you're good to merge (Wade asked me to review it). If you don't have permissions to merge, i'll happy to do that on your behalf once successful review. |
|
Hi @jake-the-dev , I've noticed a lot of spec files are missing the Copyright statement at the top. Could you please add it? Thanks |
@zinduolis Good catch. I've added those - plus added it for some other specs that were missing it 👍 Have removed the API related specs given the future deprecation and actioned your other comments too. All yours again. |
zinduolis
left a comment
There was a problem hiding this comment.
Summary
This PR significantly improves test coverage for the BeEF core using SimpleCov. It focuses strictly on beef/core and avoids changing business logic, limiting modifications to minor linting fixes.
Scope of Changes
Comprehensive test coverage for:
- Core Models & Handlers: Hooked browsers, browser details, commands, and results.
- Network Stack: Asset handling, dynamic reconstruction, and redirection.
- Filters & Utilities: Data validation filters, router logic, and Ruby core extensions.
- System Checks: Filesystem and security check verifications.
Key Discussion Points & Status
- Resolved: Added missing copyright headers to all new spec files.
- Resolved: Removed API-related tests due to future deprecation plans.
- ARE Conflict: Handled separately (acknowledging the overlap with PR #3482 removal). This PR does not touch Autorun Engine code anymore.
|
@zinduolis Looks like I don't have permissions to merge - I'll leave this with you if you'd be so kind. 🚀 |
Pull Request
Thanks for submitting a PR! Please fill in this template where appropriate:
Category
Tests
Feature/Issue Description
Q: Please give a brief summary of your feature/fix
A: Improving test coverage utilising SimpleCov for tracking. I understand this PR is massive, but I don't think there's a quick way of introducing a large amount of coverage. This may be the least painful way.
Current coverage overview:

Current result from tests:

(note, pending tests already existed)
NOTE: the creation of tests has been AI assisted but also painstakingly reviewed and adjusted for each and every file.
Q: Give a technical rundown of what you have changed (if applicable)
A: I'm going through the beef/core files and creating tests for them ensure the core functionality is tested and trusted.
Trying not to change any business logic - only some lint issues as I come across them due to updates in Ruby over time.
Test Cases
Q: Describe your test cases, what you have covered and if there are any use cases that still need addressing.
A: Anything and everything in beef/core. Not touching
beef/extensionsorbeen/modulesin this PR as it's already large enough.Wiki Page
If you are adding a new feature that is not easily understood without context, please draft a section to be added to the Wiki below.
N/A