-
Notifications
You must be signed in to change notification settings - Fork 250
Beautiful relative imports + Edited README + Fixed Travis CI :D #23
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
Conversation
Current pyt notes:
|
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.
67d2b1f:
A lot of the stuff pylint does is great.
But as you can see in the github_search module pylint does not track what names are in the globals. This means when going from module.class_name import to from module import class_name .
Stefan and i agreed on that we want PyT to be able to do what pylint does but better. As PyT actually tracks the global names so we can manage the above problem.
More on that in a task i will define.
pyt/github_search.py
Outdated
import requests | ||
import repo_runner | ||
from reaching_definitions_taint import ReachingDefinitionsTaintAnalysis | ||
from repo_runner import add_repo_to_csv, NoEntryPathError, Repo |
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.
This one breaks the github_search module as there is a Repo defined in this module aswell.
This means we have two Repo definitions in globals so the last imported overwrites the first.
pyt/github_search.py
Outdated
@@ -209,7 +210,7 @@ def scan_github(search_string, start_date, analysis_type, analyse_repo_func, csv | |||
Languages.python, repo) | |||
s = SearchCode(q) | |||
if s.results: | |||
r = repo_runner.Repo(repo.url) |
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.
This is the line we want back.
pyt/github_search.py
Outdated
@@ -209,7 +210,7 @@ def scan_github(search_string, start_date, analysis_type, analyse_repo_func, csv | |||
Languages.python, repo) | |||
s = SearchCode(q) | |||
if s.results: | |||
r = repo_runner.Repo(repo.url) | |||
r = Repo(repo.url) |
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.
This Repo is referencing the definition of Repo in this module and not the one in the repo_runner.
pyt/github_search.py
Outdated
scan_github('flask', ReachingDefinitionsTaintAnalysis) | ||
exit() | ||
q = Query(SEARCH_REPO_URL, 'flask') | ||
s = SearchRepo(q) | ||
for repo in s.results[:3]: | ||
q = Query(SEARCH_CODE_URL, 'app = Flask(__name__)', Languages.python, repo) | ||
s = SearchCode(q) | ||
r = repo_runner.Repo(repo.url) | ||
r = Repo(repo.url) |
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.
Same as above.
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.
Good catch, I will change it.
997796d |
It's necessary for the relative imports to work, I don't love having to use -m but the relative imports are worth it IMO and there's no longer any sys ../pyt hacks. Regarding the switch to I'm on my phone so I don't have the succinct stackoverflow link I had yesterday but David Beazley's awesome talk may convince you, around 41 minutes in https://www.youtube.com/watch?v=0oTh1CXRaQ0&t=2490 [edit] |
README.md
Outdated
|
||
Clone the project into the directory | ||
|
||
`git clone https://github.com/python-security/pyt.git` |
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.
This will make a pyt/pyt dir. You can clone right from ~
and it'll create a pyt dir.
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 realize pyt/pyt
is awkward, but I want python3 -m venv ~/somefolder/
that's not ~ or the Git Repository itself to hold the env files. Do you think I should I change it to mkdir ~/somefolder
to make it less confusing?
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.
Naw it works, just wanted to make sure you were accounting for it. You could change the README so that it's clear that the directory for the venv doesn't matter
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.
Good point :)
README.md
Outdated
`pip install -r requirements.txt` | ||
|
||
`pip list` sample output | ||
``` |
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.
Want an extra blank line here
README.md
Outdated
`pip list` sample output | ||
``` | ||
gitdb (0.6.4) | ||
|
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.
extra lines shouldn't be needed if the triple backticks work
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 didn't know that, thanks.
import os | ||
import sys | ||
|
||
sys.path.insert(0, os.path.abspath('../pyt')) |
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.
Great to get rid of 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.
👍
pyt/analysis_base.py
Outdated
@@ -1,5 +1,5 @@ | |||
"""Thos module contains a base class for the analysis component used in PyT.""" |
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.
fix typo?
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.
Will do
pyt/base_cfg.py
Outdated
@@ -166,12 +166,12 @@ def __init__(self, label, left_hand_side, right_hand_side_variables, ast_node, * | |||
right_hand_side_variables(list[str]): A list of variables on the right hand side. | |||
line_number(Optional[int]): The line of the expression the Node represents. | |||
""" | |||
super(ReturnNode, self).__init__(label, left_hand_side, ast_node, right_hand_side_variables, line_number=line_number, path=path) | |||
super(ReturnNode, self).__init__(label, left_hand_side, ast_node, right_hand_side_variables, line_number=line_number, path=path) |
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.
Why not use python3 super
syntax?
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.
TIL :) Thanks Graz
Great talk, i have watched it before. |
Okay, that is the last commit (barring a fix from feedback.) That I will make, this PR is not getting any bigger :) re:"PyT on pypi" I do not know but I will look into it. |
I think it will not be a problem or this is definitely not a step in the wrong direction in regards to getting PyT on pypi :) |
Also, we should add pylint to pre-commit hooks.