Commit c789c78
Drop non-unique Cleanup logic from expect step (#516)
Summary:
Pull Request resolved: #516
To enable actual clean ups and prevent errors like
```
ERROR failed to run command:
could not load TTP at /home/nesusvet/security-ttpcode/ttps/infra/tupperware/ssh-to-container-as-root.yaml:
could not parse action for step "start-tupperware-container": action fields did not match any valid action type
```
Changes pretty radical but I don't see why we need a custom implementation of cleanup logic for expect step
Consider small change to the [expect.yaml](https://www.internalfb.com/code/fbsource/fbcode/security/redteam/purple_team/ttpforge/example-ttps/actions/expect/expect.yaml) example TTP
```
hg d
diff --git a/fbcode/security/redteam/purple_team/ttpforge/example-ttps/actions/expect/expect.yaml b/fbcode/security/redteam/purple_team/ttpforge/example-ttps/actions/expect/expect.yaml
--- a/fbcode/security/redteam/purple_team/ttpforge/example-ttps/actions/expect/expect.yaml
+++ b/fbcode/security/redteam/purple_team/ttpforge/example-ttps/actions/expect/expect.yaml
@@ -26,3 +26,4 @@
response: "John"
- prompt: "Enter your age:"
response: "30"
+ cleanup: echo "Done"
```
Try to run it on master and see NO CLEANUP instructions executed:
```
buck run security/redteam/purple_team/ttpforge:ttpforge -- run security/redteam/purple_team/ttpforge/example-ttps/actions/expect/expect.yaml
File changed: fbcode//security/redteam/purple_team/ttpforge/example-ttps/actions/expect/expect.yaml
Buck UI: https://www.internalfb.com/buck2/a008be5d-79d8-4591-960a-64fafbc10a44
Network: Up: 0B Down: 0B
Jobs completed: 4. Time elapsed: 0.0s.
BUILD SUCCEEDED
INFO RUNNING TTP: Complex Expect Step with Python Script
INFO ----------------------------------------
INFO Executing Step #1: "create_python_script"
INFO ----------------------------------------
INFO Executing Step #2: "run_expect_script"
Enter your name:
John
Enter your age:
30
Hello John, you are 30 years old!
INFO ----------------------------------------
INFO All TTP steps completed successfully!
INFO ========================================
INFO CLEANING UP 2 steps of TTP: "Complex Expect Step with Python Script"
INFO ----------------------------------------
INFO Cleaning Up Step #2: "run_expect_script"
INFO No Cleanup Action Defined for Step run_expect_script
INFO ----------------------------------------
INFO Cleaning Up Step #1: "create_python_script"
INFO No Cleanup Action Defined for Step create_python_script
INFO ----------------------------------------
INFO Finished Cleanup Successfully
```
Differential Revision: D64108097
fbshipit-source-id: 2ab395b393b88ebfd0f5dd647cd75f34fce52b971 parent 50f6817 commit c789c78
3 files changed
Lines changed: 2 additions & 182 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | 33 | | |
35 | 34 | | |
36 | 35 | | |
| |||
52 | 51 | | |
53 | 52 | | |
54 | 53 | | |
55 | | - | |
56 | 54 | | |
57 | 55 | | |
58 | 56 | | |
| |||
263 | 261 | | |
264 | 262 | | |
265 | 263 | | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | 264 | | |
301 | 265 | | |
302 | 266 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
370 | 370 | | |
371 | 371 | | |
372 | 372 | | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | 373 | | |
403 | 374 | | |
404 | 375 | | |
| |||
529 | 500 | | |
530 | 501 | | |
531 | 502 | | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
537 | | - | |
538 | | - | |
539 | | - | |
540 | | - | |
541 | | - | |
542 | | - | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | | - | |
547 | | - | |
548 | | - | |
549 | | - | |
550 | | - | |
551 | | - | |
552 | | - | |
553 | | - | |
554 | | - | |
555 | | - | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
561 | | - | |
562 | | - | |
563 | | - | |
564 | | - | |
565 | | - | |
566 | | - | |
567 | | - | |
568 | | - | |
569 | | - | |
570 | | - | |
571 | | - | |
572 | | - | |
573 | | - | |
574 | | - | |
575 | | - | |
576 | | - | |
577 | | - | |
578 | | - | |
579 | | - | |
580 | | - | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | 503 | | |
585 | 504 | | |
586 | 505 | | |
| |||
698 | 617 | | |
699 | 618 | | |
700 | 619 | | |
701 | | - | |
702 | | - | |
703 | | - | |
704 | | - | |
705 | | - | |
706 | | - | |
707 | | - | |
708 | | - | |
709 | | - | |
710 | | - | |
711 | | - | |
712 | | - | |
713 | | - | |
714 | | - | |
715 | | - | |
716 | | - | |
717 | | - | |
718 | | - | |
719 | | - | |
720 | | - | |
721 | | - | |
722 | | - | |
723 | | - | |
724 | | - | |
725 | | - | |
726 | | - | |
727 | | - | |
728 | | - | |
729 | | - | |
730 | | - | |
731 | | - | |
732 | | - | |
733 | | - | |
734 | | - | |
735 | | - | |
736 | | - | |
737 | | - | |
738 | | - | |
739 | | - | |
740 | | - | |
741 | | - | |
742 | | - | |
743 | | - | |
744 | | - | |
745 | | - | |
746 | | - | |
747 | | - | |
748 | | - | |
749 | | - | |
750 | | - | |
751 | | - | |
752 | | - | |
753 | | - | |
754 | | - | |
755 | | - | |
756 | | - | |
757 | | - | |
758 | | - | |
759 | | - | |
760 | | - | |
761 | | - | |
762 | | - | |
763 | | - | |
764 | | - | |
765 | | - | |
766 | 620 | | |
767 | 621 | | |
768 | 622 | | |
| |||
0 commit comments