-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from oasis-open/53-2.1support
Support multiple STIX versions
- Loading branch information
Showing
38 changed files
with
3,895 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,3 +109,6 @@ venv.bak/ | |
|
||
# PyCharm | ||
.idea/ | ||
|
||
# Vim | ||
*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,6 @@ | |
'bumpversion', | ||
'check-manifest', | ||
'pre-commit', | ||
'readme_renderer', | ||
# test_requires are installed into every tox environemnt, so we don't | ||
# want to include tox there. | ||
'tox', | ||
|
@@ -31,6 +30,7 @@ | |
version='1.1.0', | ||
description='Validate STIX 2 Patterns.', | ||
long_description=readme, | ||
long_description_content_type='text/x-rst', | ||
url="https://github.com/oasis-open/cti-pattern-validator", | ||
author='OASIS Cyber Threat Intelligence Technical Committee', | ||
author_email='[email protected]', | ||
|
@@ -44,7 +44,8 @@ | |
'typing ; python_version<"3.5" and python_version>="3"', | ||
], | ||
package_data={ | ||
'stix2patterns.test': ['spec_examples.txt'], | ||
'stix2patterns.test.v20': ['spec_examples.txt'], | ||
'stix2patterns.test.v21': ['spec_examples.txt'], | ||
}, | ||
entry_points={ | ||
'console_scripts': [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DEFAULT_VERSION = '2.0' # Default version should always be the latest STIX 2.X version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from antlr4.error.ErrorListener import ErrorListener | ||
|
||
|
||
class STIXPatternErrorListener(ErrorListener): | ||
""" | ||
Modifies ErrorListener to collect error message and set flag to False when | ||
invalid pattern is encountered. | ||
""" | ||
def __init__(self): | ||
super(STIXPatternErrorListener, self).__init__() | ||
self.err_strings = [] | ||
|
||
def syntaxError(self, recognizer, offendingSymbol, line, column, msg, e): | ||
self.err_strings.append("FAIL: Error found at line %d:%d. %s" % | ||
(line, column, msg)) | ||
|
||
|
||
class ParserErrorListener(ErrorListener): | ||
""" | ||
Simple error listener which just remembers the last error message received. | ||
""" | ||
def syntaxError(self, recognizer, offendingSymbol, line, column, msg, e): | ||
self.error_message = u"{}:{}: {}".format(line, column, msg) | ||
|
||
|
||
class ParseException(Exception): | ||
"""Represents a parse error.""" | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
stix2patterns/test/test_inspector.py → stix2patterns/test/v20/test_inspector.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
[file:hashes.'SHA-256' = 'aec070645fe53ee3b3763059376134f058cc337247c978add178b6ccdfb0019f'] | ||
[email-message:from_ref.value MATCHES '.+\\@example\\.com$' AND email-message:body_multipart[*].body_raw_ref.name MATCHES '^Final Report.+\\.exe$'] | ||
[file:hashes.'SHA-256' = 'aec070645fe53ee3b3763059376134f058cc337247c978add178b6ccdfb0019f' AND file:mime_type = 'application/x-pdf'] | ||
[file:hashes.'SHA-256' = 'bf07a7fbb825fc0aae7bf4a1177b2b31fcf8a3feeaf7092761e18c859ee52a9c' OR file:hashes.MD5 = 'cead3f77f6cda6ec00f57d76c9a6879f'] AND [file:hashes.'SHA-256' = 'aec070645fe53ee3b3763059376134f058cc337247c978add178b6ccdfb0019f'] | ||
([file:hashes.MD5 = '79054025255fb1a26e4bc422aef54eb4'] FOLLOWEDBY [win-registry-key:key = 'HKEY_LOCAL_MACHINE\\foo\\bar']) WITHIN 300 SECONDS | ||
[user-account:account_type = 'unix' AND user-account:user_id = '1007' AND user-account:account_login = 'Peter'] AND [user-account:account_type = 'unix' AND user-account:user_id = '1008' AND user-account:account_login = 'Paul'] AND [user-account:account_type = 'unix' AND user-account:user_id = '1009' AND user-account:account_login = 'Mary'] | ||
[artifact:mime_type = 'application/vnd.tcpdump.pcap' AND artifact:payload_bin MATCHES '\\xd4\\xc3\\xb2\\xa1\\x02\\x00\\x04\\x00'] | ||
[file:name = 'foo.dll' AND file:parent_directory_ref.path = 'C:\\Windows\\System32'] | ||
[file:extensions.'windows-pebinary-ext'.sections[*].entropy > 7.0] | ||
[file:mime_type = 'image/bmp' AND file:magic_number_hex = h'ffd8'] | ||
[network-traffic:dst_ref.type = 'ipv4-addr' AND network-traffic:dst_ref.value = '203.0.113.33/32'] | ||
[network-traffic:dst_ref.type = 'domain-name' AND network-traffic:dst_ref.value = 'example.com'] REPEATS 5 TIMES WITHIN 1800 SECONDS | ||
[domain-name:value = 'www.5z8.info' AND domain-name:resolves_to_refs[*].value = '198.51.100.1/32'] | ||
[url:value = 'http://example.com/foo' OR url:value = 'http://example.com/bar'] | ||
[x509-certificate:issuer = 'CN=WEBMAIL' AND x509-certificate:serial_number = '4c:0b:1d:19:74:86:a7:66:b4:1a:bf:40:27:21:76:28'] | ||
[windows-registry-key:key = 'HKEY_CURRENT_USER\\Software\\CryptoLocker\\Files' OR windows-registry-key:key = 'HKEY_CURRENT_USER\\Software\\Microsoft\\CurrentVersion\\Run\\CryptoLocker_0388'] | ||
[(file:name = 'pdf.exe' OR file:size = '371712') AND file:created = t'2014-01-13T07:03:17Z'] | ||
[email-message:sender_ref.value = '[email protected]' AND email-message:subject = 'Conference Info'] | ||
[x-usb-device:usbdrive.serial_number = '575833314133343231313937'] | ||
[process:command_line MATCHES '^.+>-add GlobalSign.cer -c -s -r localMachine Root$'] FOLLOWEDBY [process:command_line MATCHES'^.+>-add GlobalSign.cer -c -s -r localMachineTrustedPublisher$'] WITHIN 300 SECONDS | ||
[network-traffic:dst_ref.value ISSUBSET '2001:0db8:dead:beef:0000:0000:0000:0000/64'] | ||
([file:name = 'foo.dll'] AND [win-registry-key:key = 'HKEY_LOCAL_MACHINE\\foo\\bar']) OR [process:name = 'fooproc' OR process:name = 'procfoo'] | ||
[file:hashes.MD5 = 'cead3f77f6cda6ec00f57d76c9a69faa'] |
Oops, something went wrong.