mage.api_resources.asset module

class mage.api_resources.asset.Asset

Bases: mage.api_resources.abstract.listable_api_resource.ListableAPIResource, mage.api_resources.abstract.mutable_api_resource.MutableAPIResource

asset_identifier

Identifier of the asset (e.g., ‘192.168.1.1’)

Type

str

asset_source

How this asset was created (customer defined vs discovered)

Type

mage.schema.AssetSource

asset_type

Type of the asset (e.g., ‘IP_ADDRESS’)

Type

mage.schema.AssetType

created_at

When the asset was created (e.g., ‘2020-01-02T03:04:56.789Z’)

Type

str

criticality

An integer value that represents the potential impact that the loss or compromise of the asset would have. 1 is the default (lowest) criticality. 5 is the most impactful.

Type

int

id

Unique asset ID

Type

str

tags

One or more labels or identifiers using arbitrary values (e.g., ‘app-prod’, ‘app-dev’, etc.)

Type

list of str

updated_at

When the asset was last updated (e.g., ‘2020-01-02T03:04:56.789Z’)

Type

str

property assessments

Associated assessments.

Returns

ListObject of AssessmentAssetConnection

property asset_groups

Associated asset groups.

Returns

ListObject of AssetGroupConnection

connect(item=None, assessment_id=None, assessment_run_id=None, asset_group_id=None)

Connect an asset to an assessment, assessment run, or asset group

Parameters
  • item (object, optional) – Assessment or AssessmentRun or AssetGroup to connect the asset to

  • assessment_id (str, optional) – ID of the assessment to connect the asset to

  • assessment_run_id (str, optional) – ID of the assessment run to connect the asset to

  • asset_group_id (str, optional) – ID of the asset group to connect the asset to

Returns

AssessmentAssetConnection or AssetGroupConnection or AssessmentRunAssetConnection

Example

>>> import mage
>>> mage.connect()
>>> asset = mage.Asset.eq(asset_identifier='www.example.com')[0]
>>> asset.connect(mage.Assessment.last()[0])
>>> ar = mage.AssessmentRun.last()[0]
>>> asset.connect(assessment_run_id=ar.id)
property connections

Asset relationships.

Returns

ListObject of AssetConnection

classmethod create(asset_type, id, **kwargs)

Creates a new asset.

Parameters
  • asset_type (mage.schema.AssetType) – Type of asset to create

  • id (str) – Asset identifier

  • **kwargs – Additional arguments to initialize the asset with.

Returns

The created asset

Return type

Asset

Example

>>> import mage
>>> mage.connect()
>>> mage.Asset.create('IP_ADDRESS', '192.168.1.1')
property credentials

Associated credentials.

Returns

ListObject of CredentialConnection

property findings

Associated findings.

Returns

ListObject of Finding

findings_filter()

Findings associated with this asset.

Returns

Filter

Example

>>> import mage
>>> mage.connect()
>>> asset = mage.Asset.eq(asset_identifier='www.example.com')[0]
>>> list(asset.findings().auto_paging_iter())