This repository was archived by the owner on Feb 12, 2021. It is now read-only.
Updated URLScan for archive URLs. Fixes #84#94
Open
RajuKoushik wants to merge 1 commit into
Open
Conversation
Signed-off-by: rajukoushik <g.rajukoushik@gmail.com>
JonoYang
suggested changes
Sep 27, 2017
Member
JonoYang
left a comment
There was a problem hiding this comment.
Sorry for the delay. I made a few comments regarding your code. Thanks for the contribution!
| Create and save a file at `path` present at `url` using `scan_id` and bare `path` and | ||
| `file_name` and apply the scan. | ||
| """ | ||
| r = requests.get(url) |
| url_parse = urlparse(url) | ||
| os.chdir(path) | ||
|
|
||
| if r.status_code == 200: |
Member
There was a problem hiding this comment.
We have code from extractcode in scancode that can do extractions on different archive types which may be helpful, for example https://github.com/nexB/scancode-toolkit/blob/develop/src/extractcode/extract.py#L101
| scan_directory = None | ||
| scan_id = create_scan_id(user, url, scan_directory, scan_start_time) | ||
| current_scan = Scan.objects.get(pk=scan_id) | ||
| path = '/'.join([path, '{}'.format(current_scan.pk)]) |
Member
There was a problem hiding this comment.
Use os.path.join() to ensure consistency when joining paths
| for i in allowed_exts: | ||
| if url_parse.path.endswith(i): | ||
| is_zip_url = True | ||
| finally: |
| is_zip_url = False | ||
|
|
||
| try: | ||
| for i in allowed_exts: |
Member
There was a problem hiding this comment.
We may have some code that identify whether or not files are archives or not. I will ask @pombredanne
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Signed-off-by: rajukoushik g.rajukoushik@gmail.com