Skip to content

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

Merged
wbooth merged 8 commits into
apache:masterfrom
CDJellen:master
Nov 3, 2021
Merged

Possible fix to Issue #2315 (affects templates/abilities.html)#2321
wbooth merged 8 commits into
apache:masterfrom
CDJellen:master

Conversation

@CDJellen
Copy link
Copy Markdown
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.
@mkultraWasHere mkultraWasHere added hacktoberfest https://hacktoberfest.digitalocean.com hacktoberfest-accepted hacktoberfest accepted 2025 labels Oct 29, 2021
mkultraWasHere
mkultraWasHere previously approved these changes Oct 29, 2021
Copy link
Copy Markdown
Contributor

@mkultraWasHere mkultraWasHere 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
Copy Markdown
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.

Comment thread templates/abilities.html Outdated
@CDJellen CDJellen dismissed stale reviews from argaudreau and mkultraWasHere via d718e37 November 1, 2021 21:28
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud 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

@wbooth wbooth merged commit b816e9c into apache:master Nov 3, 2021
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 2025

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants