-
Notifications
You must be signed in to change notification settings - Fork 58
Specify YAML coder for mdm payload #211
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,7 +1,11 @@ | ||
| class AddSessionTable < ActiveRecord::Migration[4.2] | ||
|
|
||
| class Event < ApplicationRecord | ||
| serialize :info | ||
| if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1 | ||
|
Contributor
Author
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. we're tab indented here for some reason, ignore the formatting it looks normal in the IDE, file was orinigally tabs so not going to change that |
||
| serialize :info, coder: YAML | ||
| else | ||
| serialize :info | ||
| end | ||
| end | ||
|
|
||
| class SessionEvent < ApplicationRecord | ||
|
|
@@ -10,7 +14,11 @@ class SessionEvent < ApplicationRecord | |
|
|
||
| class Session < ApplicationRecord | ||
| has_many :events, :class_name => 'AddSessionTable::SessionEvent' | ||
| serialize :datastore | ||
| if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1 | ||
| serialize :datastore, coder: YAML | ||
| else | ||
| serialize :datastore | ||
| end | ||
| end | ||
|
|
||
| def self.up | ||
|
|
||
This file contains hidden or 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 hidden or 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,45 @@ | ||
| RSpec.describe Mdm::Payload, type: :model do | ||
| it_should_behave_like 'Metasploit::Concern.run' | ||
|
|
||
| context 'factory' do | ||
| it 'should be valid' do | ||
| mdm_payload = FactoryBot.build(:mdm_payload) | ||
| expect(mdm_payload).to be_valid | ||
| end | ||
| end | ||
|
|
||
| context 'database' do | ||
|
|
||
| context 'timestamps'do | ||
| it { is_expected.to have_db_column(:created_at).of_type(:datetime) } | ||
| it { is_expected.to have_db_column(:updated_at).of_type(:datetime) } | ||
| end | ||
|
|
||
| context 'columns' do | ||
| it { is_expected.to have_db_column(:name).of_type(:string) } | ||
| it { is_expected.to have_db_column(:uuid).of_type(:string) } | ||
| it { is_expected.to have_db_column(:uuid_mask).of_type(:integer) } | ||
| it { is_expected.to have_db_column(:timestamp).of_type(:integer) } | ||
| it { is_expected.to have_db_column(:arch).of_type(:string) } | ||
| it { is_expected.to have_db_column(:platform).of_type(:string) } | ||
| it { is_expected.to have_db_column(:urls).of_type(:string) } | ||
| it { is_expected.to have_db_column(:description).of_type(:string) } | ||
| it { is_expected.to have_db_column(:raw_payload).of_type(:string) } | ||
| it { is_expected.to have_db_column(:raw_payload_hash).of_type(:string) } | ||
| it { is_expected.to have_db_column(:build_status).of_type(:string) } | ||
| it { is_expected.to have_db_column(:build_opts).of_type(:string) } | ||
| end | ||
| end | ||
|
|
||
| context '#destroy' do | ||
| it 'should successfully destroy the object' do | ||
| payload = FactoryBot.create(:mdm_payload) | ||
| expect { | ||
| payload.destroy | ||
| }.to_not raise_error | ||
| expect { | ||
| payload.reload | ||
| }.to raise_error(ActiveRecord::RecordNotFound) | ||
| end | ||
| end | ||
| end |
This file contains hidden or 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 hidden or 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,7 @@ | ||
| FactoryBot.define do | ||
| factory :mdm_payload, :aliases => [:payload], :class => Mdm::Payload do | ||
| # | ||
| # Associations | ||
| # | ||
| 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.
since specifying
coder:is a noop, and the old code didn't specify any coder, thisif/elsestatementi s kind of redundant, I did add in an explicitserialize :urls, YAMLbut that broke the tests and it makes more sense to keep the old functionality the same as it was beforeI don't mind keeping it here, since it makes it obvious what the intention is