This may end up being super silly but I'm using the Pyattck API to interact with the Mitre framework. It seems simple enough and what I need is very simple.
I have a list of Mitre Enterprise Technique IDs (maybe 40 or so) and I need to turn them into Tactic IDs and Tactic Names. The below code is a demonstration of doing that with the data that's already there and I get the results I want, for the most part, but I want to know how do I do this with my file or a variable (or even hardcoding the list)??
I've looked all through the documentation and there is nothing there or on the internet explaining how to do this. I take it as being a simple thing that my inexperience in coding is causing me to fail miserably on. I appreciate the help.
from pyattck import Attck
attack = Attck()
for technique in tactic.techniques:
print(technique.id)
print(technique.name)
for tactic in technique.tactics:
print(tactic.id)
print(tactic.name)
You can change the configurations. Please look at
https://github.com/swimlane/pyattck
in configuration section. You can give your file path and read the file from the path and then do your stuff.
Related
I would like to have a script ran by cron or an anki background job that will automatically read in a file (e.g. csv, tsv) containing all my flashcards and update the flashcard database in anki automatically so that i don't have to manually import my flashcards 1000 times a week.
any have any ideas how this can be achieved ?
Some interesting links I've came across, including from answers, that might provide a lead towards solutions:
https://github.com/langfield/ki
https://github.com/patarapolw/ankisync
https://github.com/towercity/anki-cli
The most robust approach there is so far is to have your collection under git, and use Ki to make Anki behave like a remote repository, so it's very easy to synchronise. The only constraint is the format of your collection. Each card is kept as a single file, and there is no real way around this.
I'm the maintainer of ki, one of the tools you linked! I really appreciate the shout-out #BlackBeans.
It's hard to give you perfect advice without more details about your workflow, but it sounds to me like you've got the source-of-truth for your notes in tabular files, and you import these files into Anki when you've made edits or added new notes.
If this is the case, ki may be what you're looking for. As #BlackBeans mentioned, this tool allows you to convert Anki notes into markdown files, and more generally, handles moving your data from your collection to a git repository, and back.
Basically, if the reason why you've got stuff in tabular files is (1) because you want to version it, (2) because you want to use an external editor, or (3) because your content is generated programmatically, then you might gain some use from using ki.
Feel free to open an issue describing your use case in detail. I'd love to give you some support in figuring out a good workflow if you think it would be helpful. I am in need of more user feedback at the moment, so you'd be helping me out, too!
I'm wondering what the "best practice" is for storing medium length strings to be used in a UI in Python/Django.
Example:
I have an error.html template that takes an error_description field. This is a few sentences explaining to the user what went wrong, and what they might do to address it. It may be different for different error pages, but remains fairly stable in the code(there's no reason that someone who can't push source code should be able to modify it), and can easily be held in memory, so I don't think it's the sort of thing that should be kept in the database.
My current idea is that I should just create some kind of messages.py file that has a bunch of string constants like this:
ERROR_UNAUTHENTICATED_AJAX_EXPLANATION = "Hello, so the only way that this error should occur is if someone attempts to directly call our AJAX endpoint without having the verification code. Please don't do this, it's against the principles of this art projects."
In general, is there some canonical way to store strings that are "too flexible to be hard coded in", but "too small and static for databases"(and don't scale with your usage)? I'm thinking of the sort of thing that would be in a strings.xml file in an Android project.
Other possibilities I'm juggling include a text file that views.py reads and stores as constants, actually just hardcoding them, and sticking them in template files.
There's a lot of ways to do this, and it's not a very complicated thing, I just want to know which one is the most 'right'.
Thanks! And let me know if you need more info!
If you are absolutely sure, these strings never need to become dynamic just create a strings.py module and drop the strings there as variables ("constants")
However, as the messages are user visible, you will most likely need to localize them at some point in your application's lifetime. Consequently, please make use of Django's excellent gettext support:
https://docs.djangoproject.com/en/1.7/topics/i18n/
This has got to be a silly question... but googling didn't actually help. Extra kudos for pycharm enabled answers. :)
I need a simple little UDP echo server (spare me the twisted advertisements please, this is a throw away thing, I just need to use it to peek at what a little embedded gadget is broadcasting). So I find section 21.21 of the Python 3 reference manual. It's a simple example that does exactly what I want.
But the same document also mentions a DatagramRequestHandler class. But there's no further explanation on how that differs from its parent class, or what it provides. I had really hoped that when I imported said class, that pycharm would somehow display a helpful popup for it, but I'm unable to discover such a thing.
Do I assume correctly, that I should just go find the source in my (macosx) install and look directly at that? is there a pattern for how people do that? My actual question here, is actually less about DatagramRequestHandler, and more about the general pattern, because this obviously will happen else where in the base docs.
(context: my traditional experience is with Smalltalk image based environments, where you can always just jump from class to class to class, and navigate quickly from application code all the way to the bowels, as a sort of exploratory way of learning and discovery)
There is an option to navigate to the declaration of the name under your cursor, Navigate->Declaration (shortcut CTRL+b in my keymap).
If you have such a question there are three things to do:
google it (eg. python DatagramRequestHandler)
use the help function in a interactive python session. eg.
import socketserver; help(socketserver.DatagramRequestHandler)
look into the code
Most of the time the first option is enough (this time I found only something in german). The result from the second option is in this "example" not so interesting or useful. So you have to use try third option.
I am specifically referring to Aroon Swartz case, he did a program to access academical DB's such as JSTOR, IEEE, ACM, elsevier, etc. efficiently, any idea of how he did that. I mean what python libraries, or a general algorithm or an explanation of how does it work, or a reference to go deeper on that. Please, don't be shy using advanced concepts.
Thank you very much.
Aroon Swartz didn't really access to JSTOR's DB. He writed a script which find URL of DB's ressources.
You can make that, with urllib2 and pygoogle. Open URL and parse it find what you want.
I want to learn it but I have no idea where to start. Everything out there suggests reading the libpurple source but I don't think I understand enough c to really get a grasp of it.
There isn't much about it yet... the intro, the howto, and the sources (here browsing them online but of course you can git clone them) are about it. In particular, the tiny example client you can get from here does have some miniscule example of use of purple's facilities (definitely not enough, but maybe it can get you started with the help of some 'dir', 'help' and the like...?)
Not sure how much help this will be but based on information from here, it seems like you just install python-purple and import and call the functions as normal Python functions.
Can't help you with a concrete example as I decided to use something else. However, one of the first things I wanted to do after I cloned the repo was remove the ecore dependency. Here's a patch submitted to the mailing list to do just that: https://garage.maemo.org/pipermail/python-purple-devel/2009-March/000000.html
Incidentally, if you're looking for AIM take a look at twisted.words. For Yahoo, trying getting the source for curphoo or zinc (both are console YMSG clients). For GTalk/Jabber, I've had good experiences with xmpppy.