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

taxonomies.get("c").machinetags_expanded() AttributeError: 'NoneType' #5

Open
jaegeral opened this issue Nov 21, 2018 · 1 comment
Open

Comments

@jaegeral
Copy link

If you try the following:

from pytaxonomies import Taxonomies
taxonomies = Taxonomies()
taxonomies.get("c").machinetags_expanded()

you get:

ile "<ipython-input-13-21c1a4715166>", line 1, in <module>
    taxonomies.get("c").machinetags_expanded()
AttributeError: 'NoneType' object has no attribute 'machinetags_expanded'

Imho I would expect all circl results (as it starts with c) or a proper error message or introduce a new method:

from pytaxonomies import Taxonomies
taxonomies = Taxonomies()
taxonomies.search("c").machinetags_expanded()

And then return the closest match (but then I would love it also searching not only in the keys but also values)

Hope that make sense.

@Rafiot
Copy link
Member

Rafiot commented Jan 3, 2019

Sorry for the late answer.

So I see what you want to do here, but it will have somewhat awkward consequences:

  1. if you have more than one match when searching, the search method should return a list, an not a single Taxonomy so directly calling machinetags_expanded won't be possible anyway.
In [7]: taxonomies.get('circl')
Out[7]: <pytaxonomies.api.Taxonomy at 0x7f910d461c50>
  1. the search method already search in all the possible fields (namespace, predicate, and value), and returns a list of the tags (or the expanded tag if you pass expanded=True), so you don't need to call machinetags_expanded()
In [5]: taxonomies.search('ci')
Out[5]: 
['ais-marking:CISA_Proprietary="true"',
 'ais-marking:CISA_Proprietary="false"',
 'circl:incident-classification="spam"',
 'circl:incident-classification="system-compromise"',
 'circl:incident-classification="scan"',
 'circl:incident-classification="denial-of-service"',
 'circl:incident-classification="copyright-issue"',
 'circl:incident-classification="phishing"',
 'circl:incident-classification="malware"',
 'circl:incident-classification="XSS"',
 'circl:incident-classification="vulnerability"',
 'circl:incident-classification="fastflux"',
 'circl:incident-classification="sql-injection"',
 'circl:incident-classification="information-leak"',
 'circl:incident-classification="scam"',
 'circl:incident-classification="cryptojacking"',
 'circl:incident-classification="locker"',
 'circl:incident-classification="screenlocker"',
 'circl:incident-classification="wiper"',
 'circl:topic="finance"',
 'circl:topic="ict"',
 'circl:topic="individual"',
 'circl:topic="industry"',
 'circl:topic="medical"',
 'circl:topic="services"',
 'circl:topic="undefined"',
 'euci:TS-UE/EU-TS',
 'euci:S-UE/EU-S',
 'euci:C-UE/EU-C',
 'euci:R-UE/EU-R',
 'ms-caro-malware-full:malware-family="Cinmus"',
 'ms-caro-malware-full:malware-family="Citeary"',
 'ms-caro-malware-full:malware-family="Ciucio"',
 'veris:asset:country="CI"',
 'veris:victim:country="CI"',
 'veris:actor:external:country="CI"',
 'veris:actor:partner:country="CI"']

In [6]: taxonomies.search('ci', expanded=True)
Out[6]: 
['ais-marking:CISA_Proprietary="true"',
 'ais-marking:CISA_Proprietary="false"',
 'circl:incident-classification="Spam"',
 'circl:incident-classification="System compromise"',
 'circl:incident-classification="Scan"',
 'circl:incident-classification="Denial of Service"',
 'circl:incident-classification="Copyright issue"',
 'circl:incident-classification="Phishing"',
 'circl:incident-classification="Malware"',
 'circl:incident-classification="XSS"',
 'circl:incident-classification="Vulnerability"',
 'circl:incident-classification="Fastflux"',
 'circl:incident-classification="SQL Injection"',
 'circl:incident-classification="Information leak"',
 'circl:incident-classification="Scam"',
 'circl:incident-classification="Cryptojacking"',
 'circl:incident-classification="Locker"',
 'circl:incident-classification="Screenlocker"',
 'circl:incident-classification="Wiper"',
 'circl:topic="Finance"',
 'circl:topic="ICT"',
 'circl:topic="Individual"',
 'circl:topic="Industry"',
 'circl:topic="Medical"',
 'circl:topic="Services"',
 'circl:topic="Undefined"',
 'euci:TS-UE/EU-TS',
 'euci:S-UE/EU-S',
 'euci:C-UE/EU-C',
 'euci:R-UE/EU-R']

Does it answer your question?

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

No branches or pull requests

2 participants