Skip to content
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 plugin field to adversaries, abilities, and planners #2345

Merged
merged 11 commits into from Nov 29, 2021

Conversation

argaudreau
Copy link
Contributor

Description

This PR adds a plugin field to adversaries, abilities, and planner objects. This field is helpful in parts of the UI for discoverability/traceability sake, and it will allow the atomic and stockpile plugin UIs to load without hanging up the whole server with an os.walk().

Tests have also been updated to check for the new field and all were passing locally. There are some small changes to the UI as well to re-enable the atomic and stockpile plugins. These will have a separate PR shortly to make use of this new field.

Type of change

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How Has This Been Tested?

I made requests to the abilities, adversaries, and planner endpoints to ensure that the objects returned contained the "plugin" field with the appropriate plugin it came from. I also ran pytest locally and all tests passed.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

@argaudreau argaudreau marked this pull request as draft November 1, 2021 19:55
@codecov
Copy link

codecov bot commented Nov 4, 2021

Codecov Report

Merging #2345 (a305d2d) into master (1587d2b) will increase coverage by 0.15%.
The diff coverage is 87.50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2345      +/-   ##
==========================================
+ Coverage   72.59%   72.74%   +0.15%     
==========================================
  Files         110      110              
  Lines        7947     7948       +1     
==========================================
+ Hits         5769     5782      +13     
+ Misses       2178     2166      -12     
Impacted Files Coverage Δ
app/objects/c_ability.py 97.47% <75.00%> (+3.21%) ⬆️
app/objects/c_planner.py 96.07% <75.00%> (+7.18%) ⬆️
app/objects/c_adversary.py 87.65% <80.00%> (+4.32%) ⬆️
app/objects/c_source.py 93.67% <100.00%> (+0.24%) ⬆️
app/service/data_svc.py 42.81% <100.00%> (+1.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1587d2b...a305d2d. Read the comment docs.

@argaudreau argaudreau marked this pull request as ready for review November 4, 2021 19:33
Copy link
Contributor

@bleepbop bleepbop left a comment

Choose a reason for hiding this comment

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

Everything looks good to me, but I'm having trouble seeing why test_replace_source is causing an error - I had fixed an issue with timestamps in another part of that test in #2328. I guess worst case scenario we could just pop the created key from the dumped objects before assert source.display_schema.dump(source) == expected_replaced_source_dump?

@argaudreau
Copy link
Contributor Author

@bleepbop I must've been behind master, just pulled it in and all checks are passing now.

bleepbop
bleepbop previously approved these changes Nov 11, 2021
Copy link
Contributor

@clenk clenk left a comment

Choose a reason for hiding this comment

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

If a YAML file is added to caldera/data/, the plugin field will be the type of object. For example, I created a new ability in the GUI, which placed a new file in data/abilities so the plugin value is abilities. Is that intentional? A better value might be data or even none (since it didn't come from any plugin).

Should sources also have a plugin field?

Will there be followon PRs to display the plugin information in the UI? I'm thinking the ability modal, adversary tab, and fact sources tab.

app/service/data_svc.py Outdated Show resolved Hide resolved
@argaudreau
Copy link
Contributor Author

If a YAML file is added to caldera/data/, the plugin field will be the type of object. For example, I created a new ability in the GUI, which placed a new file in data/abilities so the plugin value is abilities. Is that intentional? A better value might be data or even none (since it didn't come from any plugin).

Great catch, I modified it so if any object comes from a path without a plugin, it defaults to an empty string.

Should sources also have a plugin field?

Yes, I've added that as well.

Will there be followon PRs to display the plugin information in the UI? I'm thinking the ability modal, adversary tab, and fact sources tab.

There are a couple queued up that will add the plugin field across the site.

app/service/data_svc.py Outdated Show resolved Hide resolved
@bleepbop bleepbop self-requested a review November 23, 2021 16:38
Copy link
Contributor

@bleepbop bleepbop left a comment

Choose a reason for hiding this comment

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

Tests failing due to an unrelated issue addressed by #2356, but everything looks good to me!

Copy link
Contributor

@clenk clenk left a comment

Choose a reason for hiding this comment

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

LGTM!

@sonarcloud
Copy link

sonarcloud bot commented Nov 29, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@argaudreau argaudreau merged commit b478416 into master Nov 29, 2021
@argaudreau argaudreau deleted the plugin_field branch November 29, 2021 20:30
cyber-arsenull pushed a commit that referenced this pull request Dec 28, 2021
* Add plugin field to adversaries, abilities, sources, and planners
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants