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

Bugfix/issue 416 #546

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

Conversation

glasswalk3r
Copy link
Contributor

Also included other bug fixes and improvements.
Tests are also more restrictive now:

  • one must declare the port number of a exception will be raised;
  • one must declare the protocol unless "-1" is acceptable;
  • one must declare the CIDR (target or for) unless 0.0.0.0/0 is acceptable;

Copy link
Owner

@k1LoW k1LoW left a comment

Choose a reason for hiding this comment

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

I agree with the introduction of -1 and 0.0.0.0/0 notation.
However, I would like you to at least consider adding the features in a way that maintains backward compatibility.
I would like to keep the behavior except for obvious bugs ( be_opened(nil) ), and I would like to avoid erasing test cases to show it as much as possible.

its(:outbound) { should be_opened(8080).protocol('tcp').for('sg-9a8b7c6d') }
its(:outbound) { should be_opened(8080).protocol('tcp').for('group-in-other-aws-account-with-vpc-peering') }
its(:inbound) { should be_opened_only(60_000).protocol('tcp').for('100.45.67.12/32') }
its(:inbound) { should be_opened_only(70_000).protocol('tcp').for(['100.45.67.89/32', '100.45.67.12/32']) }
its(:outbound) { should be_opened_only(50_000).protocol('tcp').for('100.45.67.12/32') }
its(:inbound) { should be_opened.protocol('all').for('sg-3a4b5cd6') }
Copy link
Owner

Choose a reason for hiding this comment

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

I'm concerned about the loss of the all test.
I agree with the inclusion of -1, but would like to see all supported for backward compatibility.

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 think we can safely create an alias for it. Let me try and get back to you.

its(:inbound) { should be_opened(80).protocol('tcp').for('123.45.68.89/32') }
its(:inbound) { should be_opened(80).protocol('tcp').for('123.45.67.0/25') }
its(:inbound) { should be_opened(80).protocol('tcp').for('123.45.67.1/32') }
its(:inbound) { should_not be_opened(80).protocol('tcp').for('123.45.0.0/16') }
its(:inbound) { should be_opened(22) }
Copy link
Owner

Choose a reason for hiding this comment

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

I think that there are times when you just want to test that the port is open. So I'd like to see support for this notation as well.

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'm not sure, I would need to test from both console and SDK, but my guess is that is not acceptable to create a security group with such rule, without specifying protocol and CIDR. You can, of course, specify anywhere and all protocols, but at least this is rigidly defined.
Even if it would work, it would be a security flaw in my opinion: there is a big different about asserting that a port is opened for a specific IP or the whole internet (0.0.0.0).

Copy link
Owner

Choose a reason for hiding this comment

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

but my guess is that is not acceptable to create a security group with such rule, without specifying protocol and CIDR.

Yes.

Even if it would work, it would be a security flaw in my opinion: there is a big different about asserting that a port is opened for a specific IP or the whole internet (0.0.0.0).

Yes. This test does not specify the IP and protocol, so it will be to make sure that port 22 is open with some protocol on some IP.

Another way to say it is the negation of should_not be_opened(22).

@glasswalk3r
Copy link
Contributor Author

and I would like to avoid erasing test cases to show it as much as possible.

Those deleted test cases are just wrong: they were assuming an output from a different security group name. It's like testing security group B, but using output from the request of security group A details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants