-
Notifications
You must be signed in to change notification settings - Fork 59
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
Allow nominator for CI checks on banned calls #143
Conversation
Calls to nopanic / unwrap can be allowed by using #[allow_ci]
with open("src/" + f) as src_file: | ||
for line_no, line in enumerate(src_file): | ||
for b in banned: | ||
if b not in line or "#[allow_ci]" in line: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would need to check for #[allow_ci]
in the previous line, unless I am misreading this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this seems to work well:
https://github.com/keylime/rust-keylime/runs/1413393155?check_suite_focus=true
The previous line is just to go over the banned dict , I think this could likely be optimized a bit better using regexp, but we don't need to worry about performance too much
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like it was not even working before (it was allowing a load of unwraps).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yeah, that's a lot of unwraps - it's good to have this as an improvement.
I am seeing the line numbers reported as one off from where the unwrap()
is called, though, ex. File crypto.rs on line number 200 calls banned function: unwrap()
while I see the unwrap()
on 201: https://github.com/keylime/rust-keylime/blob/master/src/crypto.rs#L201. Not a big deal but easy to change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concern is more about the #[allow_ci]
being placed on the previous line from panic!
or unwrap()
- would that be caught here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see now, so I planned to have it on the same line as the instance of panic! / unwrap. This is how we do it on the bandit project
key.unwrap() #[allow_ci]
Here is an example of it working:
(Note, this is before you're change to increment the line by +1 so it records the correct line number).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, this makes much more sense now. Thanks for the clarification!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no worries. what you would you like to do around the naming convention? I went with allow_ci rather than a mention of panics (as it also covers unwraps as well)? I am open to suggestions here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think allow_ci
is fine for now; if we end up allowing more types of banned calls, we may want to differentiate later. Alternatively allow_banned
is possibly a little more descriptive.
@lukehinds I created a branch to test this by using There are still improvements to be made, ex. it's a bit awkward to put this on the line immediately before an |
@@ -1,5 +1,9 @@ | |||
#!/usr/bin/env python3 | |||
|
|||
''' | |||
To prevent CI failing for approved instance of banned words, add a comment: #[allow_ci] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, the more I think about it, it may be more readable to call this something like #[allow_panic]
.
Co-authored-by: Lily Sturmann <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @lukehinds
Edit: Do we need CI to pass for this to merge? And / or should I make a separate patch to either get rid of the unwraps()
or mark them as acceptable?
We can merge this and then follow up with a patch. I am fine to mark all those unwraps as allow, I imagine a lot of those will be refactored out when we work more on the crypto side. I will go ahead and merge this. |
actually, looks like I need to fix these first (the repo is stopping admin overriding for mergeing) |
Calls to nopanic / unwrap can be allowed by using #[allow_ci]