common

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(obj1, obj2 *CommonObjectProperties) (bool, int, []string)

Compare - This function will compare two objects to make sure they are the same and will return a boolean, an integer that tracks the number of problems found, and a slice of strings that contain the detailed results, whether good or bad.

func DecodeType

func DecodeType(data []byte) (objects.ObjectType, error)

DecodeType - This function will take in a slice of bytes representing a random STIX object encoded as JSON and return the STIX object type as a string. This is called from the Bundle Decode() to determine which type of STIX object the data represents, so that the data can be dispatched to the right object decoder.

Types

type CommonObjectProperties

CommonObjectProperties - This type defines the properties that are common to most STIX objects. If an object does not use all of these properties, then the Encode() function for that object will clean up and remove the properties that might get populated by mistake. Also, there will be Init() functions for each type of STIX object to help with populating the right properties for that type of object. This was done so that we would only need one type that could be used by all objects, to simplify the code.

func Decode

func Decode(data []byte) (*CommonObjectProperties, error)

Decode - This function is a simple wrapper for decoding JSON data. It will decode a slice of bytes into an actual struct and return a pointer to that object along with any errors. This is called from the Bundle Decode() if the object type can not be determined. So for custom objects, it will at least decode any of the common object properties that might be found.

func (*CommonObjectProperties) Compare

Compare - This method will compare the common properties from two objects to make sure they are the same. The common properties receiver is object 1 and the common properties passed in is object 2. This method will return an integer that tracks the number of problems and a slice of strings that contain the detailed results, whether good or bad.

func (*CommonObjectProperties) GetCommonProperties

func (o *CommonObjectProperties) GetCommonProperties() *CommonObjectProperties

GetCommonProperties - This method will return a pointer to the common properties of this object.

func (*CommonObjectProperties) InitSCO

func (o *CommonObjectProperties) InitSCO(objectType objects.ObjectType)

InitSCO - This method will initialize a STIX Cyber Observable Object by setting all of the basic properties and is called by the New() function from each object.

func (*CommonObjectProperties) InitSDO

func (o *CommonObjectProperties) InitSDO(objectType objects.ObjectType)

InitSDO - This method will initialize a STIX Domain Object by setting all of the basic properties and is called by the New() function from each object.

func (*CommonObjectProperties) InitSRO

func (o *CommonObjectProperties) InitSRO(objectType objects.ObjectType)

InitSRO - This method will initialize a STIX Relationship Object by setting all of the basic properties and is called by the New() function from each object.

func (*CommonObjectProperties) ValidSDO

func (o *CommonObjectProperties) ValidSDO() []error

ValidSDO - This method will verify and test all of the properties on a STIX Domain Object to make sure they are valid per the specification. It will return a boolean, an integer that tracks the number of problems found, and a slice of strings that contain the detailed results, whether good or bad.

type STIXObject

type STIXObject interface {
	GetCommonProperties() *CommonObjectProperties
	Valid() []error

	SetRawData(data []byte)
	SetCustomProperties(custom map[string]*json.RawMessage)
}

STIXObject - This interface defines what methods an object must have to be considered a STIX Object. So any new object that is created that inherits the CommonObjectProperties is considered a STIX Object by this code. This interface is currently used by the Bundle object to add objects to the Bundle.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL