Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

128: Allow the user to cancel interactive mode #190

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

Merged
KevinHock merged 2 commits into python-security:master from adrianbn:128_dont_ask_me_anymore
Jan 30, 2019

Conversation

Copy link
Contributor

@adrianbn adrianbn commented Dec 8, 2018

This should resolve #128. The change is so straight forward and any potential tests would be awkward, so I'm not sure we want to include specific tests for this (there were none before for interactive mode anyway).

I'm open to suggestions though.

You can manually test this change by using this sample code:

import scrypt
image_name = request.args.get('image_name')
if not image_name:
 image_name = 'foo'
foo = scrypt.outer(image_name) # Any call after ControlFlowNode caused the problem
foo = scrypt.hash(foo, 'salt')
foo = scrypt.encrypt(os.urandom(datalength), foo)
send_file(foo)

Then python -m pyt sample.py -m bb.txt -i. You can see how it does as many as you want until you answer s.

KevinHock reacted with thumbs up emoji KevinHock reacted with hooray emoji KevinHock reacted with heart emoji
@KevinHock KevinHock self-requested a review December 8, 2018 21:18
current_node.label,
chain[i - 1].left_hand_side
)
).lower()
if user_says.startswith('s'):
interactive = False
Copy link
Collaborator

@KevinHock KevinHock Dec 8, 2018

Choose a reason for hiding this comment

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

I don't think you need the interactive = False assignment because you're returning.

Copy link
Collaborator

We could make it so that for other vulnerability chains as well, it doesn't ask for user input anymore. But I think this change is definitely good and a step in the right direction, I'm happy to merge :D

(fwiw I don't think my comment on the issue was very clear.)

Copy link
Contributor Author

adrianbn commented Dec 8, 2018

That's a good point. I can make that change so that we stop it for all chains.

KevinHock reacted with thumbs up emoji

Copy link
Contributor Author

adrianbn commented Dec 9, 2018

So the last commit stops asking for all chains, but I'm not 100% satisfied. There aren't many better options without touching too much (e.g. making an Interactive/Mode object, or a Config object and making interactive one of its elements). This is easy but inelegant.

I have not fixed Travis' complaints about too many returns inside that function. While that is true, refactoring this function isn't trivial so I'd like to get some input on what's the preferred path forward, both for Travis and the general solution.

KevinHock reacted with thumbs up emoji

Copy link
Collaborator

I agree it's inelegant, but it's good code 👍

Maybe in the find_vulnerabilities def we can do something like

>>> class Interactive(): # Maybe in `vulnerability_helper.py`
... def __init__(self):
... self.on = False
... def __bool__(self):
... return self.on
... 
>>> interactive.on = interactive_mode # Where we currently do `interactive = False`

Where we rename the interactive arg to interactive_mode in that function def. I'm happy with whatever you prefer though, as I'm as unsure as you are.

Code Climate complains about a lot of things in the existing code, I don't know if there's anything we can do in this case.

Copy link
Collaborator

(Gonna go ahead and merge 👍 , if that's okay, as it's good as-is.)

@KevinHock KevinHock merged commit 3b344a3 into python-security:master Jan 30, 2019
Copy link
Contributor Author

Sorry, I'm having a hard time finding time lately due to some personal commitments. I was working on a nicer approach, but I'm happy to see this merged and we can improve it later.

KevinHock reacted with heart emoji

Copy link
Collaborator

No worries @adrianbn 👍 Same here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@KevinHock KevinHock KevinHock left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Add a "don't ask me anymore" option to the interactive mode

AltStyle によって変換されたページ (->オリジナル) /