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

AWS - xpander 1852 #25339

Conversation

johnnywilkes
Copy link
Contributor

Contributing to Cortex XSOAR Content

Make sure to register your contribution by filling the contribution registration form

The Pull Request will be reviewed only after the contribution registration form is filled.

Status

  • In Progress
  • Ready
  • In Hold - (Reason for hold)

Related Issues

https://jira-hq.paloaltonetworks.local/browse/EXPANDR-1852

Description

"AWS - Security Group Remediation v2" playbook is an improvement on V1 because instead of just applying a limited security group, this determines which SG is over-permissive and creates a copy of it without the over-permissive parts.

Screenshots

N/A

Minimum version of Cortex XSOAR

  • 6.0.0
  • 6.1.0
  • 6.2.0
  • 6.5.0

Does it break backward compatibility?

  • Yes
    • Further details:
  • No

Must have

  • Tests
  • Documentation

@content-bot content-bot added Community Contribution Form Filled Whether contribution form filled or not. Contribution Thank you! Contributions are always welcome! labels Mar 16, 2023
@content-bot content-bot changed the base branch from master to contrib/johnnywilkes_AWS-EXPANDR-1852 March 16, 2023 23:15
@content-bot
Copy link
Collaborator

Thank you for your contribution. Your generosity and caring are unrivaled! Make sure to register your contribution by filling the Contribution Registration form, so our content wizard @daryakoval will know the proposed changes are ready to bereviewed.

@gal-forer gal-forer assigned yucohen and unassigned daryakoval Mar 17, 2023
@gal-forer gal-forer requested review from yucohen and removed request for daryakoval March 17, 2023 00:17
@johnnywilkes
Copy link
Contributor Author

@yucohen , i shared demo with you

Copy link
Contributor

@yucohen yucohen left a comment

Choose a reason for hiding this comment

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

@johnnywilkes Great work!!! Please see my comments :)
@efelmandar Do you think we need a demo for the playbook? Or the linked demo will do?

Automation to determine which interface on an EC2 instance has an over-permissive security group, determine which security groups have over-permissive rules, and replace them with a copy of the security group that has only the over-permissive portion removed. Over-permissive is defined as sensitive ports (SSH, RDP, etc) being exposed to the internet via IPv4.

TODO ADD LINK AFTER PR
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a reminder so we won't forget to change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Returns:
Dict: Dict of the new SG to be used
"""
info = sg_info[0]['Contents']['AWS.EC2.SecurityGroups(val.GroupId === obj.GroupId)'][0]
Copy link
Contributor

Choose a reason for hiding this comment

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

if sg_info is a dict, why trying to get the first element?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! it is a list so I will change docstrings and types

Copy link
Contributor Author

Choose a reason for hiding this comment

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

raise ValueError('failed to pull information on EC2 instance')


''' COMMAND FUNCTION '''
Copy link
Contributor

Choose a reason for hiding this comment

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

As scripts are running in the following structure: !<script-name> arg1=... I think we can remove this comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not a problem, will remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

''' COMMAND FUNCTION '''


def aws_recreate_sg_command(args: Dict[str, Any]) -> str:
Copy link
Contributor

Choose a reason for hiding this comment

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

and also can change the method name, as it is not an XSOAR command

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changing to aws_recreate_sg

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +187 to +188
for mapping in int_sg_mapping.keys():
for sg in int_sg_mapping[mapping]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
for mapping in int_sg_mapping.keys():
for sg in int_sg_mapping[mapping]:
for mapping in int_sg_mapping.values():
for sg in mapping:

This change is optional, but this way the code is easier to read :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made this change and unit tests were breaking. Will keep as-is

@johnnywilkes
Copy link
Contributor Author

@ShirleyDenkberg , can you look this over as well, please?

@ShirleyDenkberg ShirleyDenkberg self-assigned this Mar 20, 2023
Packs/AWS-Enrichment-Remediation/README.md Outdated Show resolved Hide resolved
Packs/AWS-Enrichment-Remediation/ReleaseNotes/1_1_1.md Outdated Show resolved Hide resolved
Packs/AWS-Enrichment-Remediation/ReleaseNotes/1_1_1.md Outdated Show resolved Hide resolved
| **Argument Name** | **Description** |
| --- | --- |
| instance_id | EC2 Instance ID. |
| port | TCP/UDP Port to be restricted. |
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
| port | TCP/UDP Port to be restricted. |
| port | TCP/UDP port to be restricted. |

@ShirleyDenkberg
Copy link
Contributor

@yucohen @efelmandar Doc review completed.

johnnywilkes and others added 3 commits March 20, 2023 13:07
Co-authored-by: ShirleyDenkberg <62508050+ShirleyDenkberg@users.noreply.github.com>
@efelmandar
Copy link
Contributor

@yucohen the recorded demo is enough here, finished the review, and is ready for merge.
@johnnywilkes nice work!

@yucohen yucohen merged commit 8e95583 into demisto:contrib/johnnywilkes_AWS-EXPANDR-1852 Mar 21, 2023
17 checks passed
@content-bot content-bot mentioned this pull request Mar 21, 2023
11 tasks
yucohen added a commit that referenced this pull request Mar 22, 2023
* add automation

* init Unittest, docstrings, README, fix yml

* more format, validate and lint

* unit tests, lint and base playbook

* playbook, README, RN

* fix build issues

* update tests

* COVERAGE!!!!!

* Yuval's feedback

* simple mistake

* Apply suggestions from code review



* Update README.md

---------

Co-authored-by: johnnywilkes <32227961+johnnywilkes@users.noreply.github.com>
Co-authored-by: ShirleyDenkberg <62508050+ShirleyDenkberg@users.noreply.github.com>
Co-authored-by: yucohen <86777474+yucohen@users.noreply.github.com>
@johnnywilkes johnnywilkes mentioned this pull request Mar 22, 2023
11 tasks
@content-bot content-bot mentioned this pull request Mar 23, 2023
11 tasks
@johnnywilkes johnnywilkes deleted the AWS-EXPANDR-1852 branch July 10, 2023 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community Contribution Form Filled Whether contribution form filled or not. Contribution Thank you! Contributions are always welcome! docs-approved
Projects
None yet
6 participants