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

Updated file paths to use pathlib.Path #1583

Closed

Conversation

Aayush-Goel-04
Copy link
Contributor

closes #1534

Checklist

  • No CHANGELOG update needed
  • No new tests needed
  • No documentation update needed

@Aayush-Goel-04
Copy link
Contributor Author

Some changes are still left, will do them and give updates soon

@Aayush-Goel-04 Aayush-Goel-04 marked this pull request as draft July 6, 2023 07:40
Copy link
Collaborator

@mr-tz mr-tz left a comment

Choose a reason for hiding this comment

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

nice work, looks great on a first glance

capa/ida/helpers.py Outdated Show resolved Hide resolved
capa/main.py Outdated Show resolved Hide resolved
capa/main.py Outdated Show resolved Hide resolved
capa/render/result_document.py Outdated Show resolved Hide resolved
@Aayush-Goel-04 Aayush-Goel-04 marked this pull request as ready for review July 7, 2023 06:24
@Aayush-Goel-04 Aayush-Goel-04 force-pushed the Aayush-Goel-04/Issue#1534 branch 2 times, most recently from ab833af to 6218f31 Compare July 7, 2023 06:33
@Aayush-Goel-04 Aayush-Goel-04 requested a review from mr-tz July 7, 2023 07:13
Copy link
Collaborator

@williballenthin williballenthin left a comment

Choose a reason for hiding this comment

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

this PR is looking quite good. thank you @Aayush-Goel-04 for going through the codebase so thoroughly to update the use of path manipulation routines.

i have a few inline comments. i'll tag some of them 👀 for things i think should be addressed before we merge. other things are more questions/discussions and can optionally be addressed.

in general, i'd request that you revert changes to the capitalization of comments and logging messages. its true that the existing grammar is not good, since many sentences should be capitalized; however, even more important right now is consistency, so we should address the grammar separately and thoroughly. thanks for trying to improve this in a few places, though.

capa/ida/helpers.py Outdated Show resolved Hide resolved
capa/ida/plugin/form.py Outdated Show resolved Hide resolved
capa/main.py Outdated Show resolved Hide resolved
capa/main.py Outdated Show resolved Hide resolved
capa/main.py Outdated Show resolved Hide resolved
capa/render/result_document.py Outdated Show resolved Hide resolved
capa/rules/cache.py Outdated Show resolved Hide resolved
setup.py Outdated Show resolved Hide resolved
tests/fixtures.py Outdated Show resolved Hide resolved
tests/test_scripts.py Outdated Show resolved Hide resolved
@Aayush-Goel-04
Copy link
Contributor Author

Will work on converting args.sample type from str to pathlib.Path across capa.

Copy link
Collaborator

@mr-tz mr-tz left a comment

Choose a reason for hiding this comment

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

overall, very nice work, thanks!

capa/main.py Outdated
@@ -500,7 +501,7 @@ def get_workspace(path, format_, sigpaths):
else:
raise ValueError("unexpected format: " + format_)

viv_utils.flirt.register_flirt_signature_analyzers(vw, sigpaths)
viv_utils.flirt.register_flirt_signature_analyzers(vw, [s.as_posix() for s in sigpaths])
Copy link
Collaborator

Choose a reason for hiding this comment

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

better str vs as_posix here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will change to str representations as it will be used in runtime. Later when changes are made in viv utils package it will be changed to Path types

capa/main.py Outdated Show resolved Hide resolved
capa/render/proto/__init__.py Outdated Show resolved Hide resolved
scripts/bulk-process.py Outdated Show resolved Hide resolved

parser = argparse.ArgumentParser(description="Extract capabilities from a file")
parser.add_argument("file", help="file to extract capabilities from")
parser.add_argument("--rules", help="path to rules directory", default=os.path.abspath(RULES_PATH))
parser.add_argument("--rules", help="path to rules directory", default=RULES_PATH)
Copy link
Collaborator

Choose a reason for hiding this comment

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

does this use the string in the help output then successfully?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If no value is given then its default is RULES_PATH of type Path . else it is converted to Path later

scripts/lint.py Outdated Show resolved Hide resolved
scripts/setup-linter-dependencies.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@williballenthin williballenthin left a comment

Choose a reason for hiding this comment

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

looking great! a few more instances to change over (i think, happy to discuss) and then im excited to merge. thanks for the great work @Aayush-Goel-04

capa/main.py Outdated Show resolved Hide resolved
capa/main.py Outdated Show resolved Hide resolved
capa/main.py Outdated Show resolved Hide resolved
capa/main.py Outdated Show resolved Hide resolved
tests/fixtures.py Outdated Show resolved Hide resolved
@williballenthin
Copy link
Collaborator

williballenthin commented Jul 10, 2023

now that #1591 is merged, lets also enable flake8-use-pathlib and ensure it passes in this PR. https://gitlab.com/RoPP/flake8-use-pathlib

this should just involve adding flake8-use-pathlib==0.3.0 to the setup.py dev dependencies and ensuring the flake8 lints pass.

this will close #1599

@williballenthin williballenthin mentioned this pull request Jul 10, 2023
16 tasks
@Aayush-Goel-04 Aayush-Goel-04 force-pushed the Aayush-Goel-04/Issue#1534 branch 2 times, most recently from d1a1c68 to b84af6a Compare July 10, 2023 19:17
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Please add bug fixes, new features, breaking changes and anything else you think is worthwhile mentioning to the master (unreleased) section of CHANGELOG.md. If no CHANGELOG update is needed add the following to the PR description: [x] No CHANGELOG update needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

use pathlib.Path to represent file system paths instead of strings
3 participants