No tempfiles!
parent
eb292b3cba
commit
dfa2dbc6af
|
@ -1,3 +1,4 @@
|
|||
config.yaml
|
||||
*.egg-info
|
||||
__pycache__
|
||||
build
|
||||
|
|
|
@ -47,10 +47,11 @@ Now it's time to create all your SQL tables. Luckily OpenTaxii comes with comman
|
|||
|
||||
You're going to want to export your configuration file to a variable as well.
|
||||
```bash
|
||||
# An example of this config is in the config directory
|
||||
export OPENTAXII_CONFIG=/path/to/config.yaml
|
||||
|
||||
opentaxii-create-services -c services.yaml
|
||||
opentaxii-create-collections -c collections.yaml
|
||||
opentaxii-create-services -c config/services.yaml
|
||||
opentaxii-create-collections -c config/collections.yaml
|
||||
|
||||
# Create a user account
|
||||
# Set the username and password to whatever you want
|
||||
|
|
|
@ -20,3 +20,12 @@ logging:
|
|||
root: info
|
||||
|
||||
hooks: misp_taxii_hooks.hooks
|
||||
# Sample configuration for misp_taxii_server
|
||||
|
||||
zmq:
|
||||
host: localhost
|
||||
port: 50000
|
||||
|
||||
misp:
|
||||
url: "http://localhost"
|
||||
api: KEY
|
|
@ -1,10 +0,0 @@
|
|||
# Sample configuration for misp_taxii_server
|
||||
|
||||
zmq:
|
||||
host: localhost
|
||||
port: 50000
|
||||
|
||||
taxii:
|
||||
host: localhost
|
||||
port: 9000
|
||||
inbox: inbox
|
|
@ -14,30 +14,32 @@ from opentaxii.signals import (
|
|||
)
|
||||
|
||||
## CONFIG
|
||||
if "MISP_TAXII_CONFIG" in os.environ:
|
||||
print("Using config from {}".format(os.environ["MISP_TAXII_CONFIG"]))
|
||||
CONFIG = yaml.parse(open(os.environ["MISP_TAXII_CONFIG"], "r"))
|
||||
if "OPENTAXII_CONFIG" in os.environ:
|
||||
print("Using config from {}".format(os.environ["OPENTAXII_CONFIG"]))
|
||||
CONFIG = yaml.load(open(os.environ["OPENTAXII_CONFIG"], "r"))
|
||||
else:
|
||||
print("Trying to use env variables...")
|
||||
if "MISP_URL" in os.environ:
|
||||
misp_url = os.environ["MISP_URL"]
|
||||
else:
|
||||
print("Unkown misp URL. Set MISP_TAXII_CONFIG or MISP_URL.")
|
||||
print("Unkown misp URL. Set OPENTAXII_CONFIG or MISP_URL.")
|
||||
misp_url = "UNKNOWN"
|
||||
if "MISP_API" in os.environ:
|
||||
misp_api = os.environ["MISP_API"]
|
||||
else:
|
||||
print("Unknown misp API key. Set MISP_TAXII_CONFIG or MISP_API.")
|
||||
print("Unknown misp API key. Set OPENTAXII_CONFIG or MISP_API.")
|
||||
misp_api = "UNKNOWN"
|
||||
|
||||
CONFIG = {
|
||||
"MISP_URL" : misp_url,
|
||||
"MISP_API" : misp_api,
|
||||
"misp" : {
|
||||
"url" : misp_url,
|
||||
"api" : misp_api
|
||||
}
|
||||
}
|
||||
|
||||
MISP = pymisp.PyMISP(
|
||||
CONFIG["MISP_URL"],
|
||||
CONFIG["MISP_API"],
|
||||
CONFIG["misp"]["url"],
|
||||
CONFIG["misp"]["api"],
|
||||
)
|
||||
|
||||
def post_stix(manager, content_block, collection_ids, service_id):
|
||||
|
@ -46,13 +48,8 @@ def post_stix(manager, content_block, collection_ids, service_id):
|
|||
Will convert it to a MISPEvent and push to the server
|
||||
'''
|
||||
|
||||
# Create a temporary file to load STIX data from
|
||||
f = tempfile.SpooledTemporaryFile(max_size=10*1024, mode="w")
|
||||
f.write(content_block.content)
|
||||
f.seek(0)
|
||||
|
||||
# Load the package
|
||||
package = pymisp.tools.stix.load_stix(f)
|
||||
package = pymisp.tools.stix.load_stix(content_block.content)
|
||||
|
||||
# Check for duplicates
|
||||
for attrib in package.attributes:
|
||||
|
|
|
@ -9,3 +9,5 @@ if [ -z $MISP_TAXII_CONFIG]
|
|||
then
|
||||
echo "Warning: Variable MISP_TAXII_CONFIG not set!";
|
||||
fi
|
||||
|
||||
|
2
setup.py
2
setup.py
|
@ -13,6 +13,6 @@ setup(
|
|||
author_email="hannah.ward2@baesystems.com",
|
||||
packages=['misp_taxii_hooks'],
|
||||
install_requires=["zmq", "misp-stix-converter", "pymisp>=2.4.53", "pyaml>=3.11", "cabby>=0.1", "mysqlclient>=1.3.9", "nose>=1.3.7"],
|
||||
scripts=["start-misp-taxii.sh", "push_published_to_taxii.py"]
|
||||
scripts=["scripts/start-misp-taxii.sh", "scripts/push_published_to_taxii.py"]
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue