Security Monitoring

Analyze code

Run static analysis rules against a source code file and return violations found.

post/api/v2/static-analysis/static-analysis-server/analyze

Request

  • Base URL
    https://api.datadoghq.com
  • URL
    https://api.datadoghq.com/api/v2/static-analysis/static-analysis-server/analyze
  • Auth
    • API key in header DD-API-KEY and API key in header DD-APPLICATION-KEY
    • or OAuth 2
      Authorization code: /oauth2/v1/authorize
      Token URL: /oauth2/v1/token scopes: code_analysis_read

Request body

Example request

{
  "data": {
    "attributes": {
      "code": "aW1wb3J0IHN5cw==",
      "file_encoding": "utf-8",
      "filename": "test.py",
      "language": "python",
      "rules": [
        {
          "category": "BEST_PRACTICES",
          "checksum": "abc123def456",
          "code": "ZnVuY3Rpb24gdmlzaXQobm9kZSkge30=",
          "id": "python-best-practices/no-exit",
          "language": "python",
          "severity": "WARNING",
          "tree_sitter_query": "KGNhbGwgbmFtZTogKGF0dHJpYnV0ZSkpQHZhbA==",
          "type": "TREE_SITTER_QUERY"
        }
      ]
    },
    "type": "analysis_request"
  }
}

Response

OK

Changes

No recorded changes to this operation across all 1 revision of this API.