deepsource-mcp-server
Version:
Model Context Protocol server for DeepSource
108 lines (107 loc) • 3.32 kB
TypeScript
/**
* @fileoverview Security client for the DeepSource API
* This module provides functionality for working with DeepSource security features.
*/
import { BaseDeepSourceClient } from './base-client.js';
import { VulnerabilityOccurrence } from '../models/security.js';
import { PaginatedResponse, PaginationParams } from '../utils/pagination/types.js';
import { ReportType } from '../deepsource.js';
/**
* Compliance report data structure
* @public
*/
export interface ComplianceReport {
reportType: ReportType;
status: 'PASSING' | 'FAILING' | 'NOOP';
title: string;
description: string;
severityDistribution: {
critical: number;
major: number;
minor: number;
total: number;
};
trend?: {
label?: string;
value?: number;
changePercentage?: number;
};
categories: Array<{
name: string;
status: 'PASSING' | 'FAILING' | 'NOOP';
issueCount: number;
description?: string;
}>;
complianceScore: number;
lastUpdated: string;
}
/**
* Client for interacting with DeepSource security API
* @class
* @extends BaseDeepSourceClient
* @public
*/
export declare class SecurityClient extends BaseDeepSourceClient {
/**
* Fetches dependency vulnerabilities from a DeepSource project
* @param projectKey The project key to fetch vulnerabilities for
* @param params Optional pagination parameters
* @returns Promise that resolves to a paginated list of vulnerability occurrences
* @throws {ClassifiedError} When the API request fails
* @public
*/
getDependencyVulnerabilities(projectKey: string, params?: PaginationParams): Promise<PaginatedResponse<VulnerabilityOccurrence>>;
/**
* Fetches a compliance report for a specific report type
* @param projectKey The project key
* @param reportType The type of compliance report
* @returns Promise that resolves to compliance report if available, null otherwise
* @public
*/
getComplianceReport(projectKey: string, reportType: ReportType): Promise<ComplianceReport | null>;
/**
* Builds GraphQL query for dependency vulnerabilities
* @private
*/
private static buildVulnerabilitiesQuery;
/**
* Builds GraphQL query for compliance reports
* @private
*/
private static buildComplianceReportQuery;
/**
* Extracts vulnerabilities from GraphQL response
* @private
*/
private extractVulnerabilitiesFromResponse;
/**
* Validates if a vulnerability node has required structure
* @private
*/
private static isValidVulnerabilityNode;
/**
* Maps a vulnerability node to VulnerabilityOccurrence
* @private
*/
private static mapVulnerabilityOccurrence;
/**
* Extracts compliance report from GraphQL response
* @private
*/
private extractComplianceReportFromResponse;
/**
* Gets the GraphQL field name for a report type
* @private
*/
private static getReportFieldName;
/**
* Gets the human-readable title for a report type
* @private
*/
private static getReportTitle;
/**
* Handles errors during vulnerabilities fetching
* @private
*/
private handleVulnerabilitiesError;
}