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

BUG: API level fixups #98

Closed
wants to merge 2 commits into from
Closed

Conversation

tyhicks
Copy link
Contributor

@tyhicks tyhicks commented Oct 9, 2017

Here are some minor fixups that I identified while reviewing the API level commit (e89d182).

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 88.947% when pulling 5be3807 on tyhicks:api-level-fixups into e89d182 on seccomp:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 88.947% when pulling 2bd18be on tyhicks:api-level-fixups into e89d182 on seccomp:master.

@tyhicks
Copy link
Contributor Author

tyhicks commented Oct 10, 2017

FYI, I'm pretty sure that 8f38116 is the last commit that I'll push to this branch. I can't spot any other issues.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 88.947% when pulling 8f38116 on tyhicks:api-level-fixups into e89d182 on seccomp:master.

@pcmoore pcmoore self-requested a review October 13, 2017 20:49
@pcmoore pcmoore changed the title API level fixups BUG: API level fixups Oct 13, 2017
@@ -28,6 +28,7 @@ int main(int argc, char *argv[])
{
int rc;
unsigned int api;
const unsigned int max_api = 2;
Copy link
Member

Choose a reason for hiding this comment

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

Let's bump the max_api value up to something absurdly high, 1024 for example, and only test to make sure it is flagged as invalid. Otherwise I fear this test is going to be a bit too fragile.

@@ -40,5 +41,20 @@ int main(int argc, char *argv[])
if (api != 1)
return -3;

rc = seccomp_api_set(max_api);
Copy link
Member

Choose a reason for hiding this comment

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

See the comment above, let's drop this check.

As odd as it may sound, I'm okay with putting in explicit checks for each supported API level as the API level is added to the library.

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 should have left a comment in the code with my intentions but I was thinking that this would force anyone adding a new API level to add a set/get test for it.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I understand, and generally applaud tests like that, but I'm thinking that any new API level addition is going to require additional tests anyway so it isn't as large a concern. I guess I could be convinced that this is the Right Thing To Do if you feel strongly about it.

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 don't feel strongly about it. I just wanted to make sure you knew what I was thinking when I wrote the tests since I did a poor job of recording what I was thinking. I'll get this PR updated hopefully by EOD. Thanks!

Copy link
Member

@pcmoore pcmoore left a comment

Choose a reason for hiding this comment

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

See the comments inline for the requested changes.

raise RuntimeError("Failed getting API level 2")

try:
set_api(3)
Copy link
Member

Choose a reason for hiding this comment

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

Similar to my comments in the C variant of this test, let's bump this up to something really large, e.g. 1024.

@pcmoore
Copy link
Member

pcmoore commented Oct 17, 2017

My experiment at marking individual commits as "approved" failed miserably, so here are the patches I merged:

  • a1c4094 api: Handle all possible return values when checking flag support
  • 88f8832 system: Add missing param to sys_chk_seccomp_flag() comment
  • 6ee8df1 tests: Add new API level test binary to gitignore

The other two commits look pretty good, I just had a few small comments (made inline, if things got mangled let me know and I'll just repeat the comments here).

@pcmoore
Copy link
Member

pcmoore commented Oct 17, 2017

Oh, I forgot to add my thanks for cleaning up my mess! :)

Test setting all of the valid API levels and then test an invalid API
level to ensure that seccomp_api_set() fails.

Signed-off-by: Tyler Hicks <[email protected]>
Allow Python applications to get and set the API level using global
functions.

Signed-off-by: Tyler Hicks <[email protected]>
@tyhicks
Copy link
Contributor Author

tyhicks commented Oct 18, 2017

I've updated the C and Python test as you requested. I did away with the "max_api" variable in the C test for two reasons:

  1. It didn't exist in the Python test and that bothered me a bit.
  2. It is no longer the "max api" in the sense that it is the highest valid API level so the name no longer made sense.

My experiment at marking individual commits as "approved" failed miserably, ...

As a fellow patch-and-mailing-list dinosaur, I feel your pain. :)

(though, I'm warming up to this new world)

Oh, I forgot to add my thanks for cleaning up my mess! :)

Pfft. Thanks for helping to clean up all of my messes spread across both PRs. :)

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 88.947% when pulling a54a57c on tyhicks:api-level-fixups into a1c4094 on seccomp:master.

@pcmoore
Copy link
Member

pcmoore commented Oct 19, 2017

Thanks for the quick turnaround on the updates, everything looks good and should now be in the master branch:

  • 4f16fe2 python: Expose API level functionality
  • f9d757d tests: Improve seccomp_api_set() test coverage

@pcmoore pcmoore closed this Oct 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants