Skip to content

create_threat async

create_threat(
    agent_space_id: str,
    threat_job_id: str,
    *,
    config_overrides: Optional[AsyncSecurityAgentClientConfig] = None,
    title: Optional[str] = None,
    statement: Optional[str] = None,
    severity: Optional[ThreatSeverity] = None,
    comments: Optional[str] = None,
    stride: Optional[StrideCategoryList] = None,
    threat_source: Optional[str] = None,
    prerequisites: Optional[str] = None,
    threat_action: Optional[str] = None,
    threat_impact: Optional[str] = None,
    impacted_goal: Optional[StringList] = None,
    impacted_assets: Optional[StringList] = None,
    anchor: Optional[ThreatAnchorShape] = None,
    evidence: Optional[ThreatEvidenceList] = None,
    recommendation: Optional[str] = None,
) -> CreateThreatOutput

Creates a new threat under a threat model job.

Parameters:

  • agent_space_id (str) –

    The unique identifier of the agent space.

  • threat_job_id (str) –

    The unique identifier of the threat model job the threat belongs to.

  • title (Optional[str], default: None ) –

    A short title summarizing the threat.

  • statement (Optional[str], default: None ) –

    The natural-language threat statement.

  • severity (Optional[ThreatSeverity], default: None ) –

    The severity level of the threat.

  • comments (Optional[str], default: None ) –

    Optional customer comment on the threat.

  • stride (Optional[StrideCategoryList], default: None ) –

    The STRIDE categories applicable to this threat.

  • threat_source (Optional[str], default: None ) –

    The actor or origin of the threat.

  • prerequisites (Optional[str], default: None ) –

    The conditions required for the threat to be exploitable.

  • threat_action (Optional[str], default: None ) –

    What the threat source can do.

  • threat_impact (Optional[str], default: None ) –

    The direct consequence of the threat action.

  • impacted_goal (Optional[StringList], default: None ) –

    The security goals affected by the threat.

  • impacted_assets (Optional[StringList], default: None ) –

    The specific assets affected by the threat.

  • anchor (Optional[ThreatAnchorShape], default: None ) –

    The DFD element this threat is anchored to.

  • evidence (Optional[ThreatEvidenceList], default: None ) –

    The source code files supporting the threat.

  • recommendation (Optional[str], default: None ) –

    The recommended mitigation guidance for this threat.

Raises:

Source code in docs_src/capo_securityagent/_services/async_security_agent.py
async def create_threat(
    self,
    agent_space_id: str,
    threat_job_id: str,
    *,
    config_overrides: Optional[AsyncSecurityAgentClientConfig] = None,
    title: Optional[str] = None,
    statement: Optional[str] = None,
    severity: Optional[
        "capo_securityagent.types.threat_severity.ThreatSeverity"
    ] = None,
    comments: Optional[str] = None,
    stride: Optional[
        "capo_securityagent.types.stride_category_list.StrideCategoryList"
    ] = None,
    threat_source: Optional[str] = None,
    prerequisites: Optional[str] = None,
    threat_action: Optional[str] = None,
    threat_impact: Optional[str] = None,
    impacted_goal: Optional[
        "capo_securityagent.types.string_list.StringList"
    ] = None,
    impacted_assets: Optional[
        "capo_securityagent.types.string_list.StringList"
    ] = None,
    anchor: Optional[
        "capo_securityagent.types.threat_anchor_shape.ThreatAnchorShape"
    ] = None,
    evidence: Optional[
        "capo_securityagent.types.threat_evidence_list.ThreatEvidenceList"
    ] = None,
    recommendation: Optional[str] = None,
) -> "capo_securityagent.types.create_threat_output.CreateThreatOutput":
    """<p>Creates a new threat under a threat model job.</p>

    Args:
        agent_space_id: <p>The unique identifier of the agent space.</p>
        threat_job_id: <p>The unique identifier of the threat model job the threat belongs to.</p>
        title: <p>A short title summarizing the threat.</p>
        statement: <p>The natural-language threat statement.</p>
        severity: <p>The severity level of the threat.</p>
        comments: <p>Optional customer comment on the threat.</p>
        stride: <p>The STRIDE categories applicable to this threat.</p>
        threat_source: <p>The actor or origin of the threat.</p>
        prerequisites: <p>The conditions required for the threat to be exploitable.</p>
        threat_action: <p>What the threat source can do.</p>
        threat_impact: <p>The direct consequence of the threat action.</p>
        impacted_goal: <p>The security goals affected by the threat.</p>
        impacted_assets: <p>The specific assets affected by the threat.</p>
        anchor: <p>The DFD element this threat is anchored to.</p>
        evidence: <p>The source code files supporting the threat.</p>
        recommendation: <p>The recommended mitigation guidance for this threat.</p>

    Raises:
        capo_securityagent.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_securityagent.types.create_threat_input.CreateThreatInput]",
    ) -> AsyncOperationResponse[
        "capo_securityagent.types.create_threat_output.CreateThreatOutput"
    ]:
        import capo_securityagent._operations.security_agent.create_threat

        (
            output,
            http_response,
        ) = await capo_securityagent._operations.security_agent.create_threat.async_create_threat(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateThreat")
    )
    input_: capo_securityagent.types.create_threat_input.CreateThreatInput = {
        "agent_space_id": agent_space_id,
        "threat_job_id": threat_job_id,
    }
    if title is not None:
        input_["title"] = title
    if statement is not None:
        input_["statement"] = statement
    if severity is not None:
        input_["severity"] = severity
    if comments is not None:
        input_["comments"] = comments
    if stride is not None:
        input_["stride"] = stride
    if threat_source is not None:
        input_["threat_source"] = threat_source
    if prerequisites is not None:
        input_["prerequisites"] = prerequisites
    if threat_action is not None:
        input_["threat_action"] = threat_action
    if threat_impact is not None:
        input_["threat_impact"] = threat_impact
    if impacted_goal is not None:
        input_["impacted_goal"] = impacted_goal
    if impacted_assets is not None:
        input_["impacted_assets"] = impacted_assets
    if anchor is not None:
        input_["anchor"] = anchor
    if evidence is not None:
        input_["evidence"] = evidence
    if recommendation is not None:
        input_["recommendation"] = recommendation

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output