開発者プラットフォーム

多言語 SDK 開発者ハブ

自動再試行、型指定された結果、OpenTelemetry トレースを備えた TypeScript、Python、Go、Java 用の公式 SDK。

Select Your Language / Ecosystem
Synchronizes all examples below

パッケージのインストール

Install TypeScript:
npm install @blackshield/sdk

インタラクティブなコード例と一般的なパターン

TypeScript、Python、Go、Java にわたる実際の実装を探索します。タブを選択すると、すべての例のコード スニペットが同時に更新されます。

1. Client Initialization & Regional Routing

Establish authenticated connections with automated retries and OpenTelemetry tracing

All BlackShield SDKs support explicit regional routing (e.g. EU data residency in Ireland `eu-west-1`), automated exponential backoff on 429/5xx errors, and W3C TraceContext header propagation.

import { BlackShieldClient } from "@blackshield/sdk";

// Initialize with environment API key and regional data residency
export const blackshield = new BlackShieldClient({
  apiKey: process.env.BLACKSHIELD_API_KEY!,
  region: "eu-west-1", // Routes to https://api.eu-west-1.blackshield.chaplau.com
  timeoutMs: 30_000,
  maxRetries: 3,
  enableOpenTelemetry: true, // Injects traceparent & tracestate
});
Edge Runtime & MCP AI Agent Tools
Node.js >= 18, Next.js App Router, Cloudflare Workers

2. Querying & Filtering Vulnerability Findings

Query prioritized findings across SAST, SCA, container, and cloud scanners

Filter findings by severity, lifecycle status, CVE identifier, or affected resource. SDKs provide typed pagination and memory-efficient cursor iterators.

import { blackshield } from "./client";

export async function getCriticalVulnerabilities(serviceName: string) {
  const response = await blackshield.findings.list({
    severity: ["critical", "high"],
    status: "open",
    resourceType: "container_image",
    resourceName: serviceName,
    limit: 50,
  });

  console.log(`Found ${response.total} active findings`);
  for (const finding of response.items) {
    console.log(`[${finding.severity.toUpperCase()}] ${finding.id}: ${finding.title}`);
  }
  return response.items;
}
Edge Runtime & MCP AI Agent Tools
Node.js >= 18, Next.js App Router, Cloudflare Workers

3. Policy Guardrails & CI/CD Deployment Gates

Block non-compliant container images and unapproved dependencies before production

Evaluate deployment decisions against centralized BlackShield governance policies. Automatically halts pipelines if critical unpatched CVEs or license violations exist.

import { blackshield } from "./client";

export async function evaluateDeployGate(imageDigest: string, targetEnv: string) {
  const decision = await blackshield.policies.evaluate({
    action: "deploy",
    environment: targetEnv,
    resource: {
      type: "container_image",
      digest: imageDigest,
    },
  });

  if (!decision.allowed) {
    const reasons = decision.violations.map(v => `- ${v.rule}: ${v.message}`).join("\n");
    throw new Error(`Deployment blocked by BlackShield policy:\n${reasons}`);
  }

  console.log(`✓ Deployment approved by policy "${decision.policyPack}"`);
}
Edge Runtime & MCP AI Agent Tools
Node.js >= 18, Next.js App Router, Cloudflare Workers

4. Ingesting Telemetry & Scanner Findings

Submit batches of unified findings from bespoke or in-house scanners

Normalize findings into the BlackShield Unified Schema. Batches are ingested asynchronously, deduplicated by key, and surfaced across SOC dashboards in real time.

import { blackshield } from "./client";

export async function submitScannerResults(findingsBatch: Array<any>) {
  const result = await blackshield.ingestion.submit({
    source: {
      scanner: "custom-pipeline-scanner",
      scannerVersion: "2.4.0",
      target: "github.com/my-org/core-service",
    },
    findings: findingsBatch.map(f => ({
      findingType: "vulnerability",
      severity: f.severity,
      title: f.title,
      cveId: f.cve,
      dedupKey: `vuln:${f.cve}:${f.pkgName}@${f.installedVersion}`,
      affectedResource: {
        resourceType: "package",
        resourceName: f.pkgName,
        resourceId: f.installedVersion,
      },
    })),
  });

  console.log(`Job ID: ${result.jobId}, Ingested: ${result.submittedCount}`);
  return result;
}
Edge Runtime & MCP AI Agent Tools
Node.js >= 18, Next.js App Router, Cloudflare Workers

5. Idiomatic Ecosystem Strengths & Specializations

Showcasing language-native paradigms: MCP AI Agents, Async Streams, K8s Controllers & Spring Boot

Each BlackShield SDK is crafted natively to leverage its ecosystem's unique strengths without unnatural abstractions.

import { BlackShieldClient } from "@blackshield/sdk";
import { BlackShieldMCPAdapter } from "@blackshield/sdk/mcp";

// Model Context Protocol (MCP) AI Agent Adapter for Claude Desktop & Cursor
const client = new BlackShieldClient({ apiKey: process.env.BLACKSHIELD_API_KEY });
const mcp = new BlackShieldMCPAdapter(client);

// Expose standard JSON-RPC tools for autonomous security agents:
// - blackshield_list_findings
// - blackshield_get_finding_detail
// - blackshield_evaluate_policy
export const registeredTools = mcp.getTools();

export async function handleAgentToolCall(toolName: string, args: Record<string, any>) {
  return await mcp.executeTool(toolName, args);
}
Edge Runtime & MCP AI Agent Tools
Node.js >= 18, Next.js App Router, Cloudflare Workers

SDK アーキテクチャと機能の比較

各 SDK がその特定のランタイム、同時実行モデル、エコシステムの強みに合わせてどのように設計されているか。

Capability / Architecture
TypeScriptActive
Python
Go
Java
Package Registrynpm: @blackshield/sdkPyPI: blackshield-sdkgo.dev / S3 Module ProxyMaven Central / Gradle
Runtime TargetNode 18+, Next.js Edge, WorkersPython 3.10+, FastAPI, JupyterGo 1.22+, K8s Operators, CLIJava 17+, Spring Boot 3.x
Concurrency ModelAsync/Await (Edge native)Async (httpx/asyncio) & SyncGoroutines & ChannelsVirtual Threads & CompletableFuture
External DependenciesZero Node-only deps (Web Fetch)httpx, pydantic >= 2.0Zero external dependenciesjava.net.http, Jackson (no Netty)
Distributed TracingW3C TraceContext (traceparent)W3C TraceContext auto-injectedW3C TraceContext auto-injectedW3C TraceContext auto-injected
Automated RetriesExponential backoff + jitterExponential backoff + jitterExponential backoff + jitterExponential backoff + jitter
Ecosystem HighlightModel Context Protocol (MCP) AI ToolsAsync Streaming to Pandas / PolarsK8s Admission Webhook & ControllersSpring Boot AutoConfiguration

エンタープライズの信頼性と可観測性

分散トレーシング (W3C TraceContext)

すべての SDK は自動的に伝播されます traceparent そして tracestate API 呼び出し全体でヘッダーを生成し、AWS X-Ray、Datadog、OpenTelemetry コレクターを介したシームレスなエンドツーエンドのトレースを可能にします。

自動再試行とジッターバックオフ

過渡現象 503 Service Unavailable そして 429 Too Many Requests エラーは、アップストリームを尊重する指数バックオフとランダム化されたジッターを使用して自動的に再試行されます。 Retry-After ヘッダー。

多言語 SDK 開発者ハブ