CrowdStrike Falcon CrowdStrike Subreddit

Extensibility

Documentation Version Page Updated

FalconPy has been designed to be fully extensible, allowing developers to customize or enhance its functionality as required.

This page exists to provide documentation for developers wanting to extend native FalconPy functionality. When the goal is to interact with CrowdStrike APIs in a standardized fashion, existing functionality provided by Service Classes or the Uber Class should suffice for most scenarios.

Many of the features discussed on this page were released in the 1.3.0 version of FalconPy and are not supported in prior versions. Whenever possible, developers should upgrade to the most recent stable release in order to access the latest functionality.

FalconInterface APIHarnessV2 ServiceClass Service Classes

APIRequest Result LogFacility SDKError SDKWarning

Class types

FalconPy leverages several class types to provide developer functionality.

TypePurpose
Data ClassA generic class abstraction layer used to represent a discrete type or segment of data.
Interface ClassA generic class abstraction layer used to provide base functionality to all derivative clases that leverage it.
Derivative ClassA stand-alone class that extends the functionality provided by an interface class to deliver a solution for directly interacting with CrowdStrike APIs.

APIHarnessV2

A derivative class and an interface class combined, the Uber Class provides an all-in-one interface to the CrowdStrike Falcon API.

APIHarnessV2 directly extends UberInterface (an Uber-specific interface class that extends the FalconInterface class) by using it as a base class. This results in the Uber Class inheriting all functionality provided by the FalconInterface class. The Uber Class does not maintain an auth_object attribute, as the Uber class is an authentication object. This means the Uber Class can be used for Object Authentication just like any Service Class.

For more information on how to use the Uber Class to interact with the CrowdStrike API, please refer to the Uber Class usage documentation.

Methods

NamePurpose
authenticate

DEPRECATED
Legacy method handler for triggering a authentication request and state update. This method is deprecated, developers should move to using the updated login method to access updated functionality.
commandThe generic method handler for processing any API operation available within the CrowdStrike API. More details about the command method can be found in the Uber Class usage documentation.
deauthenticate

DEPRECATED
Legacy method handler for revoking the current API bearer token and performing a state update. This method is deprecated, developers should move to using the updated logout method to access updated functionality.
headers

DEPRECATED
Legacy method handler that returns the current authentication headers. This method is deprecated, developers should move to using the new auth_headers property to access this dictionary.
loginPerforms a request for a bearer token and updates the object's current state.
logoutPerforms a request to revoke the current API bearer token and updates the object's current state.
valid_cred_format

DEPRECATED
Legacy method handler that returns a boolean indicating if the current credential dictionary is formatted properly. This method is deprecated, developers should move to using the new cred_format_valid property to access this flag.

Properties

NamePurposeMutable?
authenticatedA boolean flag indicating if the current object is successfully authenticated to the CrowdStrike API.No
auth_headersThe authentication headers that are sent along with all requests to the CrowdStrike API. If the FalconInterface object is not currently authenticated, an authentication request will be performed when this property is referenced.No
base_urlThe base URL for the target CrowdStrike API. This can be the shortname, or the full address.Yes
bearer_tokenA data class that represents the current CrowdStrike bearer token.Yes
configThe InterfaceConfiguration object used for this authentication object.Yes
credsA dictionary containing the client_id and client_secret used to authenticate to the CrowdStrike API.Yes
cred_format_validA boolean flag indicating if the current format of the creds dictionary is valid.No
debugBoolean flag indicating if the current object has debug mode enabled.No
debug_record_countThe maximum number of records per API call performed to be logged in debug logs.Yes
logThe logger object used for this object.No
log_facilityThe attached debug logging facility for this object.No
proxyProxy dictionary that is leveraged to perform API requests from this object.Yes
pythonicA boolean flag indicating if results returned from the API should be provided as a JSON dictionary or a pythonic object.Yes
renew_windowThe amount of time in seconds before the token expires and the token is automatically refreshed.Yes
refreshableA boolean flag indicating if the current bearer token can be automatically refreshed.No
sanitize_logA boolean flag indicating if client_id, client_secret, member_cid and bearer token values should be sanitized from debug logs.Yes
ssl_verifyThe SSL verification setting (boolean or certificate location).Yes
timeoutThe connect or connect / read timeout for requests made to the CrowdStrike API.Yes
token_statusThe current API bearer token status.No
token_expiredA boolean flag indicating if the current bearer token is expired.No
token_expirationThe remaining time, in seconds, the current bearer token is considered valid.Yes
token_fail_reasonAPI authentication failure reason.No
token_renew_window

DEPRECATED
This property recreates the functionality of a legacy attribute and is deprecated. Developers should make use of the renew_window property to make changes to the token renewal window.Yes
token_timeThe timestamp when the current bearer token was generated.Yes
token_valueThe bearer token value as a string.Yes
user_agentThe User-Agent string that is sent as part of the headers for all API requests performed.Yes

Back to top


APIRequest

A generic data class comprised of several sub-classes containing all of the details for the API request to be performed.

The APIRequest object is used internally to store the details of a discrete request made to the CrowdStrike API. Most of the properties for this object, and it's sub-classes, are set when the object is constructed. These properties are defined as immutable.

Methods

NamePurpose
log_errorLeverages the attached LogFacility to log errors generated as part of a request.
log_warningLeverages the attached LogFacility to log errors generated as part of a request.

Properties

NamePurposeMutable?
metaReturns the RequestMeta data sub-class object.No
endpointThe URL route for the API request to perform.No
methodThe HTTP method for the API request to perform.No
debug_headersTemporary storage for headers returned by the request. Only used when debug logging is enabled.Yes
payloadsReturns the RequestPayloads data sub-class object.No
body_payloadThe request body content provided to the API. Typically, this is a dictionary.No
param_payloadThe query string parameters appended to the route and provided to the API. Typically, this is a dictionary.No
data_payloadThe request data content provided to the API.No
filesThe list of files to be provided along with the API request. List of tuples.No
behaviorReturns the RequestBehavior data sub-class object.No
expand_resultBoolean indicating if result expansion is enabled.No
containerBoolean indicating if this API request targets a Falcon Container endpoint.No
authenticatingBoolean indicating if this API request is performing an authentication event.No
performBoolean indicating if this API request has passed validation and should be performed.Yes
body_validatorDictionary containing body payload validation requirements for the API request to perform.No
body_requiredList of required keys that must be present within the body payload for this API request.No
request_logReturns the LogFacility sub-class object.No
log_utilReturns the underlying python Logger object from the LogFacility sub-class.No
max_debugMaximum number of records to output to a debug log.No
sanitize_logBoolean indicating if log sanitization is enabled.No
connectionReturns the RequestConnection data sub-class object.No
user_agentThe string provided as the User-Agent header when the API request is performed.No
proxyThe dictionary of proxies used for the API request.No
timeoutThe connect or connect / read timeout for performing the API request.No
verifyBoolean indicating the SSL verification status or string pointing to a local certificate file used for the API request.No

Back to top


FalconInterface

A generic object that represents the interface to the CrowdStrike Falcon API.

This class contains the default object constructor, as well as the properties and methods used by derivative classes to maintain state and authenticate to the CrowdStrike API. Typically, a developer should not need to create an instance of the FalconInterface class. This class is intended to be used an attribute or inherited as a base class.

The FalconInterface class is frequently referred to as the "authentication object" or the "auth object". For all but one of the Service Classes that leverage it, this object is available as the auth_object attribute.

The OAuth2 Service Class directly extends the FalconInterface class by using it as a base class.

The UberInterface class directly extends the FalconInterface class by using it as a base class. This class is used by the Uber Class (APIHarnessV2) as it's base class, inheriting all functionality provided by the FalconInterface class.

Methods

NamePurpose
loginLeverages a private method to perform a request for a bearer token and updates the authentication object's current state.
logoutLeverages a private method to revoke the current API bearer token and updates the object's current state.

Properties

NamePurposeMutable?
authenticatedA boolean flag indicating if the current object is successfully authenticated to the CrowdStrike API.No
auth_headersThe authentication headers that are sent along with all requests to the CrowdStrike API. If the FalconInterface object is not currently authenticated, an authentication request will be performed when this property is referenced.No
base_urlThe base URL for the target CrowdStrike API. This can be the shortname, or the full address.Yes
bearer_tokenA data class that represents the current CrowdStrike bearer token.Yes
configThe InterfaceConfiguration object used for this authentication object.Yes
credsA dictionary containing the client_id and client_secret used to authenticate to the CrowdStrike API.Yes
cred_format_validA boolean flag indicating if the current format of the creds dictionary is valid.No
debugBoolean flag indicating if the current object has debug mode enabled.No
debug_record_countThe maximum number of records per API call performed to be logged in debug logs.Yes
logThe logger object used for this object.No
log_facilityThe attached debug logging facility for this object.No
proxyProxy dictionary that is leveraged to perform API requests from this object.Yes
pythonicA boolean flag indicating if results returned from the API should be provided as a JSON dictionary or a pythonic object.Yes
renew_windowThe amount of time in seconds before the token expires and the token is automatically refreshed.Yes
refreshableA boolean flag indicating if the current bearer token can be automatically refreshed.No
sanitize_logA boolean flag indicating if client_id, client_secret, member_cid and bearer token values should be sanitized from debug logs.Yes
ssl_verifyThe SSL verification setting (boolean or certificate location).Yes
timeoutThe connect or connect / read timeout for requests made to the CrowdStrike API.Yes
token_statusThe current API bearer token status.No
token_expiredA boolean flag indicating if the current bearer token is expired.No
token_expirationThe remaining time, in seconds, the current bearer token is considered valid.Yes
token_fail_reasonAPI authentication failure reason.No
token_timeThe timestamp when the current bearer token was generated.Yes
token_valueThe bearer token value as a string.Yes
user_agentThe User-Agent string that is sent as part of the headers for all API requests performed.Yes

Back to top


LogFacility

A generic interface class that provides logging functionality for all classes and functions within the library.

Methods

NamePurpose
deactivate_logRemoves the underlying Logger object, disabling the log facility.

Properties

NamePurposeMutable?
logReturns the underlying Logger object for the log facility.No
activeBoolean indicating if this log facility is currently active.No
sanitize_logBoolean indicating if log sanitization is currently enabled for the log facility.Yes
debug_record_countInteger representing the maximum number of records the log facility will log per request performed.Yes

Back to top


Result

A generic interface class that represents the result received from the CrowdStrike API.

The Result object is comprised of multiple dynamic components that together provide two discrete styles for consuming results from CrowdStrike APIs.

StyleBenefit
DictionaryAPI results are presented in a standardized dictionary format (JSON).
PythonicAPI results are presented as Python objects that can be handled like an iterator.

The default style for consuming API results is Dictionary.

Attributes

NamePurposeData type
status_codeThe HTTP status code received for the performed request.Integer
headersAll HTTP headers received for the performed request.Headers
metaAll metadata received for the performed request.Meta
resourcesAll data results received for the performed request.Resources
errorsAll errors received for the performed request.Errors
rawThe raw result received, regardless of format.RawBody

Methods

NamePurpose
pruneReturns a list of matches for the provided substring within available results.

Properties

NamePurposeMutable?
dataReturns all data received from the underlying Resources object.No
totalReturns the total number of records matching the request performed.No
offsetReturns the current record position for the results returned.No
limitReturns the maximum number of return records allowed for the performed request.No
query_timeReturns the total execution time for the query performed.No
powered_byReturns the powered_by value for the performed request from the underlying Meta object.No
trace_idReturns the trace_id for the performed request from the underlying Meta object.No
content_encodingReturns the encoding format used for the content received in this result.No
content_typeReturns the content type received for this result.No
content_lengthReturns the total length of all content received for this result.No
dateReturns the date the request was performed.No
regionReturns the CrowdStrike region where the request was performed.No
ratelimit_limitReturns the total rate limit from the underlying Headers object.No
ratelimit_remainingReturns the remaining rate limit from the underlying Headers object.No
headers_objectBoolean flag indicating if the headers data for this result is stored as a Result object.No
meta_objectBoolean flag indicating if the meta data for this result is stored as a Meta object.No
tupledReturns the full result as a tuple. (status_code, headers, content)No
bodyReturns just the body dictionary of the API result.No
binaryBoolean flag indicating if the result is in binary format.No
full_returnReturns the full result in dictionary format.No

Back to top


SDKError

A generic interface class that is used as the base class for errors generated at runtime.

The SDKError class inherits from the Python Exception class to provide FalconPy-specific error handling.

The following custom error types are currently defined within the FalconPy SDK:

ErrorCause
APIErrorAn unexpected error was received from the CrowdStrike API.
CannotRevokeTokenThe token revocation request has failed.
FeatureNotSupportedByPythonVersionThis feature is not supported by your version of Python.
FunctionalityNotImplementedThis functionality is not currently implemented.
InvalidBaseURLThe base URL specified is invalid or unavailable.
InvalidCredentialFormatThe value provided for the creds keyword does not match the correct dictionary format.
InvalidCredentialsThe provided API credentials are invalid.
InvalidIndexThe requested position within the list or string provided does not exist.
InvalidMethodThe specified HTTP method is not accepted.
InvalidOperationThe API operation specified does not exist.
KeywordsOnlyThe specified method does not accept positional arguments, only keywords.
PayloadValidationErrorPayload validation has failed.
RegionSelectErrorCloud region auto-discovery has failed.
SDKErrorGeneric error handler leveraged for all unhandled errors.
TokenNotSpecifiedThe keyword token_value was not provided to the revoke operation.
UnsupportedPythonVersionThe version of Python you are attempting to use is not supported.

Back to top


SDKWarning

A generic interface class that is used as the base class for warnings generated at runtime.

The SDKWarning class inherits from the Python RuntimeWarning class to provide FalconPy-specific warnings.

The following custom warnings types are currently defined within the FalconPy SDK:

WarningCause
NoAuthenticationMechanismA mechanism for performing authentication to the CrowdStrike API was not specified when creating an instance of this class.
NoContentWarningThe API response indicates the request was successfully performed, but no content was receieved.
SSLDisabledWarningSSL verification has been disabled for requests made to the CrowdStrike API using this class.

Back to top


ServiceClass

A generic interface class that abstracts functionality leveraged by all derivative Service Classes.

This class extends the BaseServiceClass object, which is not intended for extensible usage outside of this scenario.

All FalconPy Service Classes, excluding OAuth2, extend the ServiceClass object to inherit common functionality.

Attributes

NamePurposeData type
auth_objectThe attached FalconInterface object used for authentication and maintaining state.FalconInterface or derivative
validate_payloadsFlag indicating if payloa1d contents sent to the API should be validated before being sent.Boolean

Methods

NamePurpose
authenticatedMethod handler that returns the current authentication state. Retrieved from the attached auth_object attribute.
loginPerforms a request for a bearer token and updates the authentication objects current state.
logoutRevokes the current API bearer token and updates the objects current state.
token_expiredMethod handler that returns the current token expiration status. Retrieved from the attached auth_object attribute.

Properties

NamePurposeMutable?
base_urlThe base URL address for the target CrowdStrike API. This can be the shortname, or the full address. This property is returned from the auth_object attribute.Yes
ssl_verifyThe SSL verification setting (boolean or certificate location). This property is returned from the auth_object attribute.Yes
logThe logger object for this object. This property can be enabled or disabled per Service Class regardless of the setting specified in the attached auth_object. When not specifically enabled or disabled, this property is returned from the auth_object attribute.No
headersThe headers that are sent for all API requests performed. This includes authentication headers that are requested from the attached auth_object and any custom headers provided when the object is created via the ext_headers keyword argument.No
tokenString representation of the current token.No
token_fail_reasonAPI authentication failure reason. This property is returned from the auth_object attribute.No
token_staleBoolean flag indicating if the current bearer token is stale.No
token_statusThe current API bearer token status. This property is returned from the auth_object attribute.No
token_validBoolean flag indicating if we have a valid authentication token.No
refreshableBoolean flag indicating if the current bearer token can be automatically refreshed. This property is returned from the auth_object attribute.No
debugBoolean flag indicating if the current object has debug mode enabled. This property can be enabled or disabled per Service Class regardless of the setting specified in the attached auth_object. When not specifically enabled or disabled, this property is returned from the auth_object attribute.No
proxyProxy dictionary that is leveraged to perform API requests from this object. This property can be set to a unique value per Service Class regardless of the setting specified in the attached auth_object. When not specifically set, this property is returned from the auth_object attribute.Yes
renew_windowThe amount of time in seconds before the token expires and the token is automatically refreshed. This property is returned from the auth_object attribute. Changing this value will impact all classes that leverage this same authentication object.Yes
token_renew_window

DEPRECATED
This property recreates the functionality of a legacy attribute and is deprecated. Developers should make use of the renew_window property to make changes to the token renewal window.Yes
timeoutAmount of time before considering a connection as timed out. When specififying a float for this value, the timeout is used for the entire request. When specified as a tuple this is used for read and connect.Yes
user_agentThe User-Agent string that is sent as part of the headers for all API requests performed. This property can be set to a unique value per Service Class regardless of the setting specified in the attached auth_object. When not specifically set, this property is returned from the auth_object attribute.Yes
debug_record_countThe maximum number of records per API call performed to be logged in debug logs. This property can be set to a unique value per Service Class regardless of the setting speficied in the attached auth_object. When not specificially set, this property is returned from the auth_object attribute.Yes
sanitize_logBoolean flag indicating if client_id, client_secret, member_cid and bearer token values should be sanitized from debug logs. This property can be enabled or disabled per Service Class regardless of the setting specified in the attached auth_object. When not specifically enabled or disabled, this property is returned from the auth_object attribute.Yes
pythonicBoolean flag indicating if results returned from the API should be provided as a JSON dictionary or a pythonic object. This property can be enabled or disabled per Service Class regardless of the setting specified in the attached auth_object. When not specifically enabled or disabled, this property is returned from the auth_object attribute.No

Back to top


Service Classes

Derivative classes that represent individual CrowdStrike API service collections, each Service Class contains methods that represent every API operation within the collection.

Service Classes extend the ServiceClass class by using it as a base class and inheriting it's attributes, methods and properties.

Service Classes can also be inherited, allowing developers to implement additional methods for extending core Servicee Class functionality.

Each Service Class will contain a PEP8 compliant method name, as well as an alias for the Operation ID (if this ID does not match PEP8 formatting requirements), for every operation within the service collection it represents. More details regarding these methods and their usage can be found in the service collection documentation for the specific API in question or the Operations by Collection page.

For more information regarding how to use Service Classes to interact with the CrowdStrike API, please review the Service Class usage documentation.

Back to top