-
Notifications
You must be signed in to change notification settings - Fork 41
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 #198 from chrisr3d/master
Fixed timestamp fields comparison
- Loading branch information
Showing
37 changed files
with
623 additions
and
60 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
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,52 @@ | ||
import copy | ||
import json | ||
|
||
from . import ValidatorTest | ||
from ... import validate_string | ||
|
||
VALID_CAMPAIGN = u""" | ||
{ | ||
"type": "campaign", | ||
"id": "campaign--0c7b5b88-8ff7-4a4d-aa9d-feb398cd0061", | ||
"created": "2023-03-17T13:37:42.596Z", | ||
"modified": "2023-09-27T20:12:54.984Z", | ||
"created_by_ref": "identity--f431f809-377b-45e0-aa1c-6a4751cae5ff", | ||
"name": "Operation Dream Job", | ||
"description": "Operation Dream Job was a cyber espionage operation likely conducted by Lazarus Group.", | ||
"aliases": [ | ||
"Operation Dream Job", | ||
"Operation North Star", | ||
"Operation Interception" | ||
], | ||
"first_seen": "2019-09-01T04:00:00.000Z", | ||
"last_seen": "2020-08-01T04:00:00.000Z" | ||
} | ||
""" | ||
|
||
|
||
class CampaignTestCases(ValidatorTest): | ||
valid_campaign = json.loads(VALID_CAMPAIGN) | ||
|
||
def test_wellformed_campaign(self): | ||
results = validate_string(VALID_CAMPAIGN, self.options) | ||
self.assertTrue(results.is_valid) | ||
|
||
def test_invalid_timestamp(self): | ||
campaign = copy.deepcopy(self.valid_campaign) | ||
campaign['created'] = "2016-09-31T08:17:27.000Z" | ||
self.assertFalseWithOptions(campaign) | ||
|
||
campaign['created'] = "2023-09-27T20:12:54.985Z" | ||
self.assertFalseWithOptions(campaign) | ||
|
||
campaign['modified'] = "2023-09-27T20:12:54.985Z" | ||
self.assertTrueWithOptions(campaign) | ||
|
||
campaign['first_seen'] = "2019-09-31T04:00:00.000Z" | ||
self.assertFalseWithOptions(campaign) | ||
|
||
campaign['first_seen'] = "2020-08-01T04:00:00.001Z" | ||
self.assertFalseWithOptions(campaign) | ||
|
||
campaign['last_seen'] = "2020-08-01T04:00:00.001Z" | ||
self.assertTrueWithOptions(campaign) |
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,36 @@ | ||
import copy | ||
import json | ||
|
||
from . import ValidatorTest | ||
from ... import validate_string | ||
|
||
VALID_COURSE_OF_ACTION = u""" | ||
{ | ||
"type": "course-of-action", | ||
"id": "course-of-action--8e2e2d2b-17d4-4cbf-938f-98ee46b3cd3f", | ||
"created_by_ref": "identity--f431f809-377b-45e0-aa1c-6a4751cae5ff", | ||
"created": "2016-04-06T20:03:48.000Z", | ||
"modified": "2016-04-06T20:03:48.000Z", | ||
"name": "mitigation-poison-ivy-firewall", | ||
"description": "Recommended steps to respond to the Poison Ivy malware" | ||
} | ||
""" | ||
|
||
|
||
class CoATestCases(ValidatorTest): | ||
valid_course_of_action = json.loads(VALID_COURSE_OF_ACTION) | ||
|
||
def test_wellformed_coa(self): | ||
results = validate_string(VALID_COURSE_OF_ACTION, self.options) | ||
self.assertTrue(results.is_valid) | ||
|
||
def test_invalid_timestamp(self): | ||
coa = copy.deepcopy(self.valid_course_of_action) | ||
coa['created'] = "2016-11-31T01:00:00.000Z" | ||
self.assertFalseWithOptions(coa) | ||
|
||
coa['created'] = "2016-04-06T20:03:48.123Z" | ||
self.assertFalseWithOptions(coa) | ||
|
||
coa['modified'] = "2016-04-06T20:03:48.123Z" | ||
self.assertTrueWithOptions(coa) |
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
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
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
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
Oops, something went wrong.