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

Possible fix to Issue #2315 (affects templates/abilities.html) #2321

Merged
merged 8 commits into from Nov 3, 2021

Conversation

CDJellen
Copy link
Contributor

@CDJellen CDJellen commented Oct 13, 2021

Possible fix to Issue #2315 (unable to create new ability)

Affects: templates/abilities.html
Change: ensure the executor.cleanup object conforms to the type expected by API v2.

Description

The REST API expects an ability object in which the cleanup field is an array (list) of strings. Currently, the "Create Ability" UI saves the cleanup command as a string, causing an Unprocessable Entity response status code (422) when executing the PUT request in API v2.

This commit includes a slight change to the cleanup field in the Create Ability modal which converts a line-break separated list of cleanup commands to the correct type. The net effect of the change is to enable users to create and edit abilities which include cleanup commands through the UI and API v2.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

  1. Created a new ability My test ability in accordance with the User Certificate in the training plugin which:
  • Has a name and description,
  • Is indexed under the discovery tactic,
  • uses sandcat.go-darwin as an executor,
  • runs the whoami command,
  • has a timeout of 60 seconds, and
  • includes ifconfig -a as a cleanup command;
  1. Edited an exiting ability to include a new cleanup command rm;
  2. Verified response status codes in browser;
  3. Used the Swagger docs to execute a GET request, verifying the changes to both abilities.

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

The REST API expects an ability object in which the cleanup field is an array (list) of strings. Currently, the "Create Ability" UI saves the cleanup command as a string, causing an Unprocessable Entity response status code (422) when executing the PUT request in API v2.  This commit includes a slight change to the cleanup field in the Create Ability modal which converts a line-break separated list of cleanup commands to the correct type.  The net effect of the change is to enable users to create and edit abilities which include cleanup commands through the UI and API v2.
Ensure correct typing in `transformCleanup` under the Alpine.js framework.
Redone cleanup commands to enable easy and intuitive addition and removal of cleanup commands.
Propagate change to ability modal to `profiles.html`.
Changes to create ability modal incorporating Adam's UI fixes and backend change to the cleanup field.
Incorporate the changes to the create ability modal to the `profiles.html` template.
@elegantmoose elegantmoose added hacktoberfest https://hacktoberfest.digitalocean.com hacktoberfest-accepted hacktoberfest accepted 2021 labels Oct 29, 2021
elegantmoose
elegantmoose previously approved these changes Oct 29, 2021
Copy link
Contributor

@elegantmoose elegantmoose left a comment

Choose a reason for hiding this comment

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

@CDJellen LGTM.

Lets have @argaudreau have final review of HTML.

argaudreau
argaudreau previously approved these changes Nov 1, 2021
Copy link
Contributor

@argaudreau argaudreau left a comment

Choose a reason for hiding this comment

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

Works as intended and HTML is super clean! I hope alpine and bulma were easy to pick up.

templates/abilities.html Outdated Show resolved Hide resolved
@CDJellen CDJellen dismissed stale reviews from argaudreau and elegantmoose via d718e37 November 1, 2021 21:28
@sonarcloud
Copy link

sonarcloud bot commented Nov 2, 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
No Duplication information No Duplication information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest https://hacktoberfest.digitalocean.com hacktoberfest-accepted hacktoberfest accepted 2021
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants