-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add Archive
and GitArchive
output formats
#173
Draft
AI-Mozi
wants to merge
1
commit into
ronin-rb:0.2.0
Choose a base branch
from
AI-Mozi:add_archive_and_git_archive_output_formats
base: 0.2.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# frozen_string_literal: true | ||
# | ||
# ronin-recon - A micro-framework and tool for performing reconnaissance. | ||
# | ||
# Copyright (c) 2023-2024 Hal Brodigan ([email protected]) | ||
# | ||
# ronin-recon is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Lesser General Public License as published | ||
# by the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# ronin-recon is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public License | ||
# along with ronin-recon. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
|
||
require 'ronin/web/spider/archive' | ||
|
||
module Ronin | ||
module Recon | ||
module OutputFormats | ||
# | ||
# Represents a web archive directory. | ||
# | ||
class Archive | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename class to |
||
|
||
# | ||
# Initializes new archive. | ||
# | ||
# @param [String] root | ||
# The path to the root directory. | ||
# | ||
def initialize(root) | ||
@archive = Ronin::Web::Spider::Archive.new(root) | ||
end | ||
|
||
# | ||
# Writes a new URL to it's specific file. | ||
# | ||
# @param [Value] value | ||
# The value to write. | ||
# | ||
def <<(value) | ||
if Values::URL === value | ||
@archive.write(value.uri, value.body) | ||
end | ||
end | ||
|
||
end | ||
end | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# frozen_string_literal: true | ||
# | ||
# ronin-recon - A micro-framework and tool for performing reconnaissance. | ||
# | ||
# Copyright (c) 2023-2024 Hal Brodigan ([email protected]) | ||
# | ||
# ronin-recon is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU Lesser General Public License as published | ||
# by the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# ronin-recon is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public License | ||
# along with ronin-recon. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
|
||
require 'ronin/web/spider/git_archive' | ||
|
||
module Ronin | ||
module Recon | ||
module OutputFormats | ||
# | ||
# Represents a web archive directory that is backed by Git. | ||
# | ||
class GitArchive | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rename class to |
||
|
||
# | ||
# Initializes new Git repository. | ||
# | ||
# @param [String] root | ||
# The path to the root directory. | ||
# | ||
def initialize(root) | ||
@git_archive = Ronin::Web::Spider::GitArchive.new(root) | ||
@git_archive.init unless @git_archive.git? | ||
end | ||
|
||
# | ||
# Writes a new URL to it's specific file in Git archive. | ||
# | ||
# @param [Value] value | ||
# The value to write. | ||
# | ||
def <<(value) | ||
if Values::URL === value | ||
@git_archive.write(value.uri, value.body) | ||
end | ||
end | ||
|
||
end | ||
end | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require 'spec_helper' | ||
require 'ronin/recon/output_formats/archive' | ||
require 'ronin/recon/values/url' | ||
require 'ronin/recon/values/domain' | ||
require 'tmpdir' | ||
|
||
describe Ronin::Recon::OutputFormats::Archive do | ||
subject { described_class.new(path) } | ||
|
||
let(:path) { Dir.mktmpdir('ronin-recon-output-archive') } | ||
|
||
describe "#<<" do | ||
context "for Values::URL" do | ||
let(:value) { Ronin::Recon::Values::URL.new('https://www.example.com/foo.html') } | ||
let(:expected_path) { File.join(path,value.path) } | ||
|
||
it "must create a new file with webpage" do | ||
subject << value | ||
|
||
expect(File.exist?(expected_path)).to be(true) | ||
end | ||
end | ||
|
||
context "for other values" do | ||
let(:value) { Ronin::Recon::Values::Domain.new('example.com') } | ||
|
||
it "must not create any files" do | ||
subject << value | ||
|
||
expect(Dir.glob("#{path}/*")).to be_empty | ||
end | ||
end | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require 'spec_helper' | ||
require 'ronin/recon/output_formats/git_archive' | ||
require 'ronin/recon/values/url' | ||
require 'ronin/recon/values/domain' | ||
require 'tmpdir' | ||
|
||
describe Ronin::Recon::OutputFormats::GitArchive do | ||
subject { described_class.new(path) } | ||
|
||
let(:path) { Dir.mktmpdir('ronin-recon-output-git-archive') } | ||
|
||
describe "#<<" do | ||
context "for Values::URL" do | ||
let(:value) { Ronin::Recon::Values::URL.new('https://www.example.com/foo.html') } | ||
let(:expected_path) { File.join(path,value.path) } | ||
|
||
it "must create a new file with webpage" do | ||
subject << value | ||
|
||
expect(File.exist?(expected_path)).to be(true) | ||
end | ||
end | ||
|
||
context "for other values" do | ||
let(:value) { Ronin::Recon::Values::Domain.new('example.com') } | ||
|
||
it "must not create any files" do | ||
subject << value | ||
|
||
expect(Dir.glob("#{path}/*")).to be_empty | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename classes to
WebArchive
andGitArchive
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file-exts can be omitted now that they are optional.