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

Parse tome paramdefs on startup #298

Merged
merged 47 commits into from
Oct 5, 2023

Conversation

hulto
Copy link
Collaborator

@hulto hulto commented Oct 1, 2023

What type of PR is this?:

/kind bug

What this PR does / why we need it:

  • Switches the tome name to use the metadata file instead of file name.
  • Calls SetParamDefs during tome parsing
  • Updated the example metadata.yml file with example paramdefs.
  • Increases the max length of the param defs field form 256 bytes to 4GB

Which issue(s) this PR fixes:

Fixes #295

@hulto hulto added the tavern label Oct 1, 2023
@hulto hulto linked an issue Oct 1, 2023 that may be closed by this pull request
Copy link
Collaborator

@alexcote1 alexcote1 left a comment

Choose a reason for hiding this comment

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

Looks good, glad that static hello world is no longer there

Copy link

Choose a reason for hiding this comment

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

What did meowware ever do to you smh

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Broke my heart 💔

@KCarretto
Copy link
Collaborator

We can make the paramdefs be more readable in the yaml, e.g.

'''
paramdefs:

  • name: msg
    label: Message
    '''

@hulto
Copy link
Collaborator Author

hulto commented Oct 1, 2023

We can make the paramdefs be more readable in the yaml, e.g.

'''
paramdefs:

  • name: msg
    label: Message
    '''

I can play with it more but when I tried that ^ it doesn't parse right since I think everything is expecting a JSON string.
We could do some gross reparsing to turn the yaml into a JSON string.

@codecov
Copy link

codecov bot commented Oct 1, 2023

Codecov Report

Merging #298 (d302962) into main (7ffe6ba) will decrease coverage by 0.05%.
The diff coverage is 64.00%.

@@            Coverage Diff             @@
##             main     #298      +/-   ##
==========================================
- Coverage   74.84%   74.80%   -0.05%     
==========================================
  Files          94       94              
  Lines        6106     6131      +25     
==========================================
+ Hits         4570     4586      +16     
- Misses       1450     1458       +8     
- Partials       86       87       +1     
Files Coverage Δ
implants/imix/src/main.rs 77.81% <100.00%> (+0.04%) ⬆️
implants/lib/eldritch/src/lib.rs 92.75% <ø> (ø)
tavern/internal/ent/schema/quest.go 38.77% <100.00%> (+3.99%) ⬆️
tavern/internal/ent/schema/tome.go 67.16% <100.00%> (+1.53%) ⬆️
tavern/tomes/parse.go 51.68% <50.00%> (-0.43%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@hulto
Copy link
Collaborator Author

hulto commented Oct 1, 2023

Actually I think we should prioritize consistency between the standard tomes and uploaded tomes.
Since uploaded tomes require paramDefs be a JSON string we should keep the standard ones with the JSON string.

If we want to re-do paramDefs to not be a JSON string we can do that later but for now I think we should stick with the agreed on paramDefs format.

@hulto hulto added the bug Something isn't working label Oct 1, 2023
@hulto hulto added this to the minor fixes before IRSEC milestone Oct 1, 2023
@hulto hulto requested a review from KCarretto October 1, 2023 20:41
@hulto
Copy link
Collaborator Author

hulto commented Oct 1, 2023

Gonna pass to @cmp5987
Looks like the front end isn't passing paramdefs rn.
image

parameters: Some(r#"{"cmd":"echo main_loop_test_success"}"#.to_string())

We need to add the "parameters" field to the formatVariables in the createQuestMutation
The parameters value should be a JSON string following the format {"key_name":"key_value"}

@cmp5987 pointed out this is confusing especially since the defs follow the pattern: {"name":"key_name","type":"type_value_type"} which is a more standard way to use objects.

The params, and paramdefs work flow should probably be re-worked at a later date so we're not using JSON strings at all.

@hulto
Copy link
Collaborator Author

hulto commented Oct 1, 2023

image Working now had to pass the params the right way.

@hulto
Copy link
Collaborator Author

hulto commented Oct 2, 2023

Issue with golang.
image

$ cat /tmp/port_scan/metadata.yml 
name: Port scan
description: Scan a list of ports in a list of CIDRs.
paramdefs: "[{\"name\":\"cidrs\",\"label\":\"CIDRs\",\"type\":\"string\",\"placeholder\":\"['192.168.0.0./24','10.102.9.11/32']\"},{\"name\":\"ports\",\"label\":\"Ports\",\"type\":\"list\",\"placeholder\":\"[22,80,443]\"},{\"name\":\"protocol\",\"label\":\"Protocol\",\"type\":\"string\",\"placeholder\":\"tcp\"},{\"name\":\"timeout\",\"label\":\"Timeout\",\"type\":\"int\",\"placeholder\":\"2\"]"%                                                                                                                                                    ```

@hulto hulto removed this from the minor fixes before IRSEC milestone Oct 2, 2023
@hulto
Copy link
Collaborator Author

hulto commented Oct 2, 2023

  • add a test to parse go that validates passing no "paramdefs" is valid.

@hulto hulto force-pushed the 295-creating-new-tasks-doesnt-prompt-for-parameters branch from a1ba38e to 700fccb Compare October 3, 2023 03:04
@KCarretto KCarretto merged commit d29a4a0 into main Oct 5, 2023
6 checks passed
@KCarretto KCarretto deleted the 295-creating-new-tasks-doesnt-prompt-for-parameters branch October 5, 2023 21:47
KCarretto pushed a commit that referenced this pull request Feb 1, 2024
 
Parse tome paramdefs on startup (#298)

* Set paramdefs on parse.

* Removes debug statements.

* Should fix tests

* Missed this one

* Updated UI.

* Yay this works.

* Remove debug statements.

* Remove debug.

* Rebuild UI.

* auto reformat paramdefs to a JSON string.

* Increase param def string size.

* Updated UI

* Add a non param example.

* Add default value to params

* Remove test.

* Rebuild ui.

* Remove test tome.

* Add test 3

* Remove example 3

* Try updating parameters too.

* Manually generated

* Switch back to entry name metadata name is complex

* Increase quest output drawer size (#306)

* Set paramdefs on parse.

* Removes debug statements.

* Should fix tests

* Missed this one

* Updated UI.

* Yay this works.

* Remove debug statements.

* Remove debug.

* Rebuild UI.

* auto reformat paramdefs to a JSON string.

* Increase param def string size.

* Updated UI

* Add a non param example.

* Add default value to params

* Remove test.

* Rebuild ui.

* Remove test tome.

* Add test 3

* Remove example 3

* Try updating parameters too.

* Manually generated

* Switch back to entry name metadata name is complex

* Update UI.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tavern
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Creating new tasks doesn't prompt for parameters
4 participants