Skip to content

Commit 56b4338

Browse files
committed
Merge pull request #65 from MAECProject/relative_imports
Relative imports
2 parents 87f4dd6 + efae099 commit 56b4338

29 files changed

+214
-147
lines changed

docs/api_vs_bindings/api_snippet.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
.. code-block:: python
22
33
# Import the required APIs
4-
from maec.bundle.bundle import Bundle
5-
from maec.bundle.malware_action import MalwareAction
4+
from maec.bundle import Bundle, MalwareAction
65
from maec.utils import IDGenerator, set_id_method
76
from cybox.core import Object, AssociatedObjects, AssociatedObject, AssociationType
87
from cybox.objects.file_object import File

docs/examples.rst

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ different types of analysis.
3232

3333
.. testcode::
3434

35-
from maec.package.package import Package
36-
from maec.package.malware_subject import MalwareSubject
35+
from maec.package import Package, MalwareSubject
3736
from maec.utils import IDGenerator, set_id_method
3837

3938
set_id_method(IDGenerator.METHOD_INT)
@@ -65,7 +64,7 @@ that it is characterizing.
6564

6665
.. testcode::
6766

68-
from maec.package.malware_subject import MalwareSubject
67+
from maec.package import MalwareSubject
6968
from maec.utils import IDGenerator, set_id_method
7069
from cybox.core import Object
7170
from cybox.objects.file_object import File
@@ -111,7 +110,7 @@ instance that it is characterizing.
111110

112111
.. testcode::
113112

114-
from maec.bundle.bundle import Bundle
113+
from maec.bundle import Bundle
115114
from maec.utils import IDGenerator, set_id_method
116115
from cybox.core import Object
117116
from cybox.objects.file_object import File
@@ -148,8 +147,8 @@ be defined in their parent Malware Subject.
148147

149148
.. testcode::
150149

151-
from maec.package.malware_subject import MalwareSubject
152-
from maec.bundle.bundle import Bundle
150+
from maec.package import MalwareSubject
151+
from maec.bundle import Bundle
153152
from maec.utils import IDGenerator, set_id_method
154153
from cybox.core import Object
155154
from cybox.objects.file_object import File
@@ -195,8 +194,8 @@ needed.
195194

196195
.. testcode::
197196

198-
from maec.bundle.bundle import Bundle
199-
from maec.bundle.malware_action import MalwareAction
197+
from maec.bundle import Bundle
198+
from maec.bundle import MalwareAction
200199
from maec.utils import IDGenerator, set_id_method
201200
from cybox.core import Object, AssociatedObjects, AssociatedObject, AssociationType
202201
from cybox.objects.file_object import File

docs/getting_started.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ Creating a MAEC Package
3030

3131
.. code-block:: python
3232
33-
from maec.package.package import Package # Import the MAEC Package API
34-
from maec.package.malware_subject import MalwareSubject # Import the MAEC Malware Subject API
33+
from maec.package import Package # Import the MAEC Package API
34+
from maec.package import MalwareSubject # Import the MAEC Malware Subject API
3535
36-
package = Package() # Create an instance of Package
37-
malware_subject = MalwareSubject() # Create an instance of MalwareSubject
38-
package.add_malware_subject(malware_subject) # Add the Malware Subject to the Package
36+
package = Package() # Create an instance of Package
37+
malware_subject = MalwareSubject() # Create an instance of MalwareSubject
38+
package.add_malware_subject(malware_subject) # Add the Malware Subject to the Package
3939
40-
print(package.to_xml()) # Print the XML for this MAEC Package
40+
print(package.to_xml()) # Print the XML for this MAEC Package
4141
4242
Parsing MAEC XML
4343
****************

examples/comparator_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pprint
22
import maec.bindings.maec_bundle as maec_bundle_binding
3-
from maec.bundle.bundle import Bundle
3+
from maec.bundle import Bundle
44
# Matching properties dictionary
55
match_on_dictionary = {'FileObjectType': ['file_name'],
66
'WindowsRegistryKeyObjectType': ['hive', 'values.name/data'],

examples/package_generation_example.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,8 @@
88
from cybox.core import AssociatedObjects, AssociatedObject, Object, AssociationType
99
from cybox.common import Hash, HashList
1010
from cybox.objects.file_object import File
11-
from maec.bundle.bundle import Bundle, Collections
12-
from maec.bundle.malware_action import MalwareAction
13-
from maec.bundle.capability import Capability
14-
from maec.package.analysis import Analysis
15-
from maec.package.malware_subject import MalwareSubject
16-
from maec.package.package import Package
11+
from maec.bundle import Bundle, Collections, MalwareAction, Capability
12+
from maec.package import Analysis, MalwareSubject, Package
1713
from cybox.utils import Namespace
1814
import maec.utils
1915

maec/analytics/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from .distance import Distance, StaticFeatureVector, DynamicFeatureVector
2+
from .static_features import static_features_dict

maec/bundle/__init__.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,30 @@
1-
_namespace = 'http://maec.mitre.org/XMLSchema/maec-bundle-4'
1+
_namespace = 'http://maec.mitre.org/XMLSchema/maec-bundle-4'
2+
3+
import maec
4+
from .malware_action import (MalwareAction, ActionImplementation, APICall,
5+
ParameterList, Parameter)
6+
from .object_reference import ObjectReferenceList, ObjectReference
7+
from .av_classification import AVClassification, AVClassifications
8+
from .behavior_reference import BehaviorReference
9+
from .behavior import (Behavior, AssociatedCode, BehaviorPurpose, Exploit,
10+
CVEVulnerability, PlatformList, BehavioralActions,
11+
BehavioralAction, BehavioralActionReference,
12+
BehavioralActionEquivalenceReference)
13+
from .action_reference_list import ActionReferenceList
14+
from .candidate_indicator import (CandidateIndicatorList, CandidateIndicator,
15+
CandidateIndicatorComposition, MalwareEntity)
16+
from .process_tree import ProcessTree, ProcessTreeNode
17+
from .bundle_reference import BundleReference
18+
from .capability import (CapabilityList, Capability, CapabilityObjective,
19+
CapabilityProperty, CapabilityRelationship,
20+
CapabilityObjectiveRelationship, CapabilityReference,
21+
CapabilityObjectiveReference)
22+
from .object_history import ObjectHistoryEntry, ObjectHistory
23+
from .bundle import (Bundle, BehaviorReference, Collections,
24+
CandidateIndicatorCollectionList, ObjectCollectionList,
25+
ActionCollectionList, BehaviorCollectionList,
26+
CandidateIndicatorCollection, ObjectCollection,
27+
BehaviorCollection, ActionCollection, BaseCollection,
28+
ObjectList, ActionList, BehaviorList)
29+
30+

maec/bundle/action_reference_list.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
from cybox.core import ActionReference
1010

1111
import maec
12+
from . import _namespace
1213
import maec.bindings.maec_bundle as bundle_binding
1314

1415

1516
class ActionReferenceList(maec.EntityList):
1617
_contained_type = ActionReference
1718
_binding_class = bundle_binding.ActionReferenceListType
1819
_binding_var = "Action_Reference"
19-
_namespace = maec.bundle._namespace
20+
_namespace = _namespace
2021

maec/bundle/av_classification.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
# Last updated 09/26/2014
88

99
import maec
10+
from . import _namespace
1011
import maec.bindings.maec_bundle as bundle_binding
1112
from cybox.common import ToolInformation
1213

1314
class AVClassification(ToolInformation, maec.Entity):
14-
_namespace = maec.bundle._namespace
15+
_namespace = _namespace
1516
_binding = bundle_binding
1617
_binding_class = bundle_binding.AVClassificationType
1718

@@ -66,4 +67,4 @@ class AVClassifications(maec.EntityList):
6667
_contained_type = AVClassification
6768
_binding_class = bundle_binding.AVClassificationsType
6869
_binding_var = "AV_Classification"
69-
_namespace = maec.bundle._namespace
70+
_namespace = _namespace

maec/bundle/behavior.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,42 @@
77
# Last updated 08/27/2014
88

99
import maec
10+
from . import _namespace
1011
import maec.bindings.maec_bundle as bundle_binding
12+
from maec.bundle import MalwareAction
1113
from cybox.core.action_reference import ActionReference
1214
from cybox.common.measuresource import MeasureSource
1315
from cybox.common.platform_specification import PlatformSpecification
14-
from maec.bundle.malware_action import MalwareAction
1516
from cybox.objects.code_object import Code
1617
#from maec.bundle.bundle import ActionCollection
1718
import datetime
1819

1920
class BehavioralActionEquivalenceReference(maec.Entity):
2021
_binding = bundle_binding
2122
_binding_class = bundle_binding.BehavioralActionEquivalenceReferenceType
22-
_namespace = maec.bundle._namespace
23+
_namespace = _namespace
2324

2425
action_equivalence_idref = maec.TypedField('action_equivalence_idref')
2526
behavioral_ordering = maec.TypedField('behavioral_ordering')
2627

2728
class BehavioralActionReference(ActionReference):
2829
_binding = bundle_binding
2930
_binding_class = bundle_binding.BehavioralActionReferenceType
30-
_namespace = maec.bundle._namespace
31+
_namespace = _namespace
3132

3233
behavioral_ordering = maec.TypedField('behavioral_ordering')
3334

3435
class BehavioralAction(maec.Entity):
3536
_binding = bundle_binding
3637
_binding_class = bundle_binding.BehavioralActionType
37-
_namespace = maec.bundle._namespace
38+
_namespace = _namespace
3839

3940
behavioral_ordering = maec.TypedField('behavioral_ordering')
4041

4142
class BehavioralActions(maec.Entity):
4243
_binding = bundle_binding
4344
_binding_class = bundle_binding.BehavioralActionsType
44-
_namespace = maec.bundle._namespace
45+
_namespace = _namespace
4546

4647
#action_collection = maec.TypedField('Action_Collection', ActionCollection, multiple=True) #TODO: solve recursive import
4748
action = maec.TypedField('Action', BehavioralAction, multiple=True)
@@ -53,20 +54,20 @@ class PlatformList(maec.EntityList):
5354
_binding_class = bundle_binding.PlatformListType
5455
_binding_var = "Platform"
5556
_contained_type = PlatformSpecification
56-
_namespace = maec.bundle._namespace
57+
_namespace = _namespace
5758

5859
class CVEVulnerability(maec.Entity):
5960
_binding = bundle_binding
6061
_binding_class = bundle_binding.CVEVulnerabilityType
61-
_namespace = maec.bundle._namespace
62+
_namespace = _namespace
6263

6364
cve_id = maec.TypedField('cve_id')
6465
description = maec.TypedField('Description')
6566

6667
class Exploit(maec.Entity):
6768
_binding = bundle_binding
6869
_binding_class = bundle_binding.ExploitType
69-
_namespace = maec.bundle._namespace
70+
_namespace = _namespace
7071

7172
known_vulnerability = maec.TypedField('known_vulnerability')
7273
cve = maec.TypedField('CVE', CVEVulnerability)
@@ -76,7 +77,7 @@ class Exploit(maec.Entity):
7677
class BehaviorPurpose(maec.Entity):
7778
_binding = bundle_binding
7879
_binding_class = bundle_binding.BehaviorPurposeType
79-
_namespace = maec.bundle._namespace
80+
_namespace = _namespace
8081

8182
description = maec.TypedField('Description')
8283
vulnerability_exploit = maec.TypedField('Vulnerability_Exploit', Exploit)
@@ -86,12 +87,12 @@ class AssociatedCode(maec.EntityList):
8687
_binding_class = bundle_binding.AssociatedCodeType
8788
_binding_var = "Code_Snippet"
8889
_contained_type = Code
89-
_namespace = maec.bundle._namespace
90+
_namespace = _namespace
9091

9192
class Behavior(maec.Entity):
9293
_binding = bundle_binding
9394
_binding_class = bundle_binding.BehaviorType
94-
_namespace = maec.bundle._namespace
95+
_namespace = _namespace
9596

9697
id_ = maec.TypedField('id')
9798
ordinal_position = maec.TypedField('ordinal_position')

0 commit comments

Comments
 (0)