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

is_url almost always returns true so can't load JSON from disk #121

Closed
thebleucheese opened this issue Aug 4, 2022 · 4 comments · Fixed by #123
Closed

is_url almost always returns true so can't load JSON from disk #121

thebleucheese opened this issue Aug 4, 2022 · 4 comments · Fixed by #123
Assignees
Labels
bug Something isn't working need_more_info This tag describes that this issue is lacking enough detail to investigate.

Comments

@thebleucheese
Copy link

Hey, I ran into a quirk trying to use JSON files from disk. Tracked it down to the is_url() function

utils.py line 26

Environment is ubuntu / poetry / python 3.8.10

Quick sample of testing just this function:

from urllib.parse import urlparse

def is_url(value: str) -> bool:
    try:
        urlparse(value).scheme in ["http", "https"]
        return True
    except Exception as e:
        pass
    return False

if __name__ == '__main__':
    print(is_url("TEST NOT A URL"))
True

And since the configuration.py get_data() call uses the URL check to determine where to load config data from, it's always calling the request getter to load from URL.

@thebleucheese
Copy link
Author

And one more note - I get a stacktrace with use_config=True

Traceback (most recent call last):
  File "/path/to/project/main.py", line 28, in <module>
    print_attack()
  File "/path/to/project/main.py", line 13, in print_attack
    attack = Attck(nested_techniques=True,
  File "/poetry-dir-fLaP9Psg-py3.8/lib/python3.8/site-packages/pyattck/attck.py", line 222, in __init__
    Base.config = Options(
  File "<attrs generated init pyattck.configuration.Options>", line 15, in __init__
  File "/poetry-dir-fLaP9Psg-py3.8/lib/python3.8/site-packages/pyattck/configuration.py", line 154, in __attrs_post_init__
    self.config = self._read_from_disk(self.config_file_path)
  File "/poetry-dir-fLaP9Psg-py3.8/lib/python3.8/site-packages/attr/_make.py", line 642, in _frozen_setattrs
    raise FrozenInstanceError()
attr.exceptions.FrozenInstanceError

Looks like use_config is trying to modify something set as immutable by attrs

@MSAdministrator
Copy link
Collaborator

@thebleucheese Can you tell me which version you are seeing this on?

@MSAdministrator MSAdministrator self-assigned this Aug 24, 2022
@MSAdministrator MSAdministrator added bug Something isn't working need_more_info This tag describes that this issue is lacking enough detail to investigate. labels Aug 24, 2022
@MSAdministrator
Copy link
Collaborator

@thebleucheese Actually, just found it and have a fix. Looking at the second thing you mentioned now.

@MSAdministrator
Copy link
Collaborator

@thebleucheese Actually just figured that one out as well. This will be released in 7.0.0 #123

@MSAdministrator MSAdministrator linked a pull request Aug 24, 2022 that will close this issue
MSAdministrator added a commit that referenced this issue Aug 24, 2022
…used. Also fixed issue with is_url method Closes #121
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working need_more_info This tag describes that this issue is lacking enough detail to investigate.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants