diff --git a/app/models/wp_item.rb b/app/models/wp_item.rb index 152e8aac..112c6614 100644 --- a/app/models/wp_item.rb +++ b/app/models/wp_item.rb @@ -112,30 +112,34 @@ module WPScan @classify ||= classify_slug(slug) end - # @return [ String ] The readme url if found + # @return [ String, False ] The readme url if found, false otherwise def readme_url return if detection_opts[:mode] == :passive - if @readme_url.nil? - READMES.each do |path| - return @readme_url = url(path) if Browser.get(url(path)).code == 200 + return @readme_url unless @readme_url.nil? + + READMES.each do |path| + if Browser.instance.forge_request(url(path), blog.head_or_get_params).run.code == 200 + return @readme_url = url(path) end end - @readme_url + @readme_url = false end - # @return [ String, false ] The changelog url if found + # @return [ String, false ] The changelog url if found, false otherwise def changelog_url return if detection_opts[:mode] == :passive - if @changelog_url.nil? - CHANGELOGS.each do |path| - return @changelog_url = url(path) if Browser.get(url(path)).code == 200 + return @changelog_url unless @changelog_url.nil? + + CHANGELOGS.each do |path| + if Browser.instance.forge_request(url(path), blog.head_or_get_params).run.code == 200 + return @changelog_url = url(path) end end - @changelog_url + @changelog_url = false end # @param [ String ] path diff --git a/spec/shared_examples/views/main_theme.rb b/spec/shared_examples/views/main_theme.rb index 14b7bd3b..8a652c8f 100644 --- a/spec/shared_examples/views/main_theme.rb +++ b/spec/shared_examples/views/main_theme.rb @@ -22,8 +22,9 @@ shared_examples 'App::Views::MainTheme' do before do expect(target).to receive(:content_dir).at_least(1).and_return('wp-content') - # Stub the checks for error/debug logs and readmes to 404 - stub_request(:head, /.*/).and_return(status: 404) + # Stub all requests to 200, to detect a readme and changelog. + # Detection of the error_log will fail as the empty body won't match the patterns + stub_request(:head, /.*/) stub_request(:get, /.*/) stub_request(:get, /.*\.css\z/)