@codacy/codacy-mcp
Version:
Codacy MCP server
455 lines (454 loc) • 21.8 kB
JavaScript
import { OpenAPI } from '../core/OpenAPI.js';
import { request as __request } from '../core/request.js';
export class SecurityService {
/**
* Deprecated: use [SearchSecurityItems](#searchsecurityitems) instead. Returns a paginated list of security and risk management items for an organization. Repository filtering is limited to 100 names.
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return* @param repositories Deprecated, use [SearchOrganizationRepositoriesWithAnalysis](#searchorganizationrepositorieswithanalysis) instead* @param status Security issue status to filter by. See [SrmStatus](#tocssrmstatus) for possible values.* @param priority Security issue priorities to filter by. See [SrmPriority](#tocssrmpriority) for possible values.* @param category Security categories to filter by. Use `_other_` to search for issues that don't have a security category.* @param scanType Security scan type to filter by. * @returns SrmItemsResponse Returns security and risk management items.
* @throws ApiError
*/
static listSecurityItems(provider, remoteOrganizationName, cursor, limit = 100, repositories, status, priority, category, scanType, abortSignal) {
return __request(OpenAPI, {
method: 'GET',
url: '/organizations/{provider}/{remoteOrganizationName}/security/items',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
},
query: {
'cursor': cursor,
'limit': limit,
'repositories': repositories,
'status': status,
'priority': priority,
'category': category,
'scanType': scanType,
},
abortSignal,
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
/**
* Ignores a single item, with optional comment as to why
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param srmItemId Id of the security and risk management item.* @param requestBody Request body of ignore item information * @returns SrmItemResponse Returns a security and risk management item.
* @throws ApiError
*/
static ignoreSecurityItem(provider, remoteOrganizationName, srmItemId, requestBody, abortSignal) {
return __request(OpenAPI, {
method: 'POST',
url: '/organizations/{provider}/{remoteOrganizationName}/security/items/{srmItemId}/ignore',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
'srmItemId': srmItemId,
},
abortSignal,
body: requestBody,
mediaType: 'application/json',
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
/**
* Unignores a single item. Only previously ignored items can be unignored.
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param srmItemId Id of the security and risk management item. * @returns SrmItemResponse Returns a security and risk management item.
* @throws ApiError
*/
static unignoreSecurityItem(provider, remoteOrganizationName, srmItemId, abortSignal) {
return __request(OpenAPI, {
method: 'POST',
url: '/organizations/{provider}/{remoteOrganizationName}/security/items/{srmItemId}/unignore',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
'srmItemId': srmItemId,
},
abortSignal,
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
/**
* Returns a single security and risk management finding.
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param srmItemId Id of the security and risk management item. * @returns SrmItemResponse Returns security and risk management items.
* @throws ApiError
*/
static getSecurityItem(provider, remoteOrganizationName, srmItemId, abortSignal) {
return __request(OpenAPI, {
method: 'GET',
url: '/organizations/{provider}/{remoteOrganizationName}/security/items/{srmItemId}',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
'srmItemId': srmItemId,
},
abortSignal,
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
/**
* Returns a paginated list of security and risk management items for an organization.
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return* @param sort Field to sort SRM items by.* @param direction Sort direction. Possible values are 'asc' (ascending) or 'desc' (descending).* @param requestBody Request body with items filters. * @returns SrmItemsResponse Returns security and risk management items.
* @throws ApiError
*/
static searchSecurityItems(provider, remoteOrganizationName, cursor, limit = 100, sort, direction, requestBody, abortSignal) {
return __request(OpenAPI, {
method: 'POST',
url: '/organizations/{provider}/{remoteOrganizationName}/security/items/search',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
},
query: {
'cursor': cursor,
'limit': limit,
'sort': sort,
'direction': direction,
},
abortSignal,
body: requestBody,
mediaType: 'application/json',
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
/**
* Deprecated: use [SearchSecurityDashboard](#searchsecuritydashboard) instead. Returns the metrics for the security and risk management dashboard. Repository filtering is limited to 100 names.
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param repositories Deprecated, use [SearchOrganizationRepositoriesWithAnalysis](#searchorganizationrepositorieswithanalysis) instead* @param priority Security issue priorities to filter by. See [SrmPriority](#tocssrmpriority) for possible values.* @param category Security categories to filter by. Use `_other_` to search for issues that don't have a security category.* @param scanType Security scan type to filter by. * @returns SRMDashboardResponse Successful operation
* @throws ApiError
*/
static getSecurityDashboard(provider, remoteOrganizationName, repositories, priority, category, scanType, abortSignal) {
return __request(OpenAPI, {
method: 'GET',
url: '/organizations/{provider}/{remoteOrganizationName}/security/dashboard',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
},
query: {
'repositories': repositories,
'priority': priority,
'category': category,
'scanType': scanType,
},
abortSignal,
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
/**
* Returns the metrics for the security and risk management dashboard.
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param requestBody Request body with dashboard filters. * @returns SRMDashboardResponse Successful operation
* @throws ApiError
*/
static searchSecurityDashboard(provider, remoteOrganizationName, requestBody, abortSignal) {
return __request(OpenAPI, {
method: 'POST',
url: '/organizations/{provider}/{remoteOrganizationName}/security/dashboard',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
},
abortSignal,
body: requestBody,
mediaType: 'application/json',
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
/**
* Returns a list of repositories with security findings. If no filter is specified, only the 10 repositories with the most findings are returned.
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param requestBody Request body with filters. * @returns SRMDashboardRepositoriesResponse Successful operation
* @throws ApiError
*/
static searchSecurityDashboardRepositories(provider, remoteOrganizationName, requestBody, abortSignal) {
return __request(OpenAPI, {
method: 'POST',
url: '/organizations/{provider}/{remoteOrganizationName}/security/dashboard/repositories/search',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
},
abortSignal,
body: requestBody,
mediaType: 'application/json',
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
/**
* Returns the evolution of security findings over time.
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param requestBody Request body with filters. * @returns SRMDashboardHistoryResponse Successful operation
* @throws ApiError
*/
static searchSecurityDashboardHistory(provider, remoteOrganizationName, requestBody, abortSignal) {
return __request(OpenAPI, {
method: 'POST',
url: '/organizations/{provider}/{remoteOrganizationName}/security/dashboard/history/search',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
},
abortSignal,
body: requestBody,
mediaType: 'application/json',
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
/**
* Returns a list of security categories with findings. If no filter is specified, only the 10 categories with the most findings are returned.
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param requestBody Request body with filters. * @returns SRMDashboardCategoriesResponse Successful operation
* @throws ApiError
*/
static searchSecurityDashboardCategories(provider, remoteOrganizationName, requestBody, abortSignal) {
return __request(OpenAPI, {
method: 'POST',
url: '/organizations/{provider}/{remoteOrganizationName}/security/dashboard/categories/search',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
},
abortSignal,
body: requestBody,
mediaType: 'application/json',
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
/**
* Upload dynamic application security testing (DAST) scan report generated by the specified tool in the specified format
* @param provider Git provider* @param remoteOrganizationName * @param toolName The tool used to generate the DAST results* @param formData * @returns SRMDASTReportUploadResponse Report successfully uploaded.
* @throws ApiError
*/
static uploadDastReport(provider, remoteOrganizationName, toolName, formData, abortSignal) {
return __request(OpenAPI, {
method: 'POST',
url: '/organizations/{provider}/{remoteOrganizationName}/security/tools/dast/{toolName}/reports',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
'toolName': toolName,
},
abortSignal,
formData: formData,
mediaType: 'multipart/form-data',
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
/**
* Consult uploaded dynamic application security testing (DAST) scan reports and their state. Results are sorted by their submission date, from latest to earliest.
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return * @returns SRMDastReportResponse Successful operation
* @throws ApiError
*/
static listDastReports(provider, remoteOrganizationName, cursor, limit = 100, abortSignal) {
return __request(OpenAPI, {
method: 'GET',
url: '/organizations/{provider}/{remoteOrganizationName}/security/dast/reports',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
},
query: {
'cursor': cursor,
'limit': limit,
},
abortSignal,
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
/**
* Returns a paginated list of organization admins and security managers.
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return * @returns SecurityManagersResponse Returns security managers, including organization admins.
* @throws ApiError
*/
static listSecurityManagers(provider, remoteOrganizationName, cursor, limit = 100, abortSignal) {
return __request(OpenAPI, {
method: 'GET',
url: '/organizations/{provider}/{remoteOrganizationName}/security/managers',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
},
query: {
'cursor': cursor,
'limit': limit,
},
abortSignal,
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
/**
* Assign the Security Manager role to an organization member.
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param requestBody User ID of the organization member to be promoted to security manager. * @returns void
* @throws ApiError
*/
static postSecurityManager(provider, remoteOrganizationName, requestBody, abortSignal) {
return __request(OpenAPI, {
method: 'POST',
url: '/organizations/{provider}/{remoteOrganizationName}/security/managers',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
},
abortSignal,
body: requestBody,
mediaType: 'application/json',
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
/**
* Revoke the Security Manager role from an organization member.
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param userId Identifier of the organization member * @returns void
* @throws ApiError
*/
static deleteSecurityManager(provider, remoteOrganizationName, userId, abortSignal) {
return __request(OpenAPI, {
method: 'DELETE',
url: '/organizations/{provider}/{remoteOrganizationName}/security/managers/{userId}',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
'userId': userId,
},
abortSignal,
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
/**
* Return a list of organization repositories that have security issues.
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return* @param segments Filter by a comma separated list of segment ids. * @returns SecurityRepositoriesResponse Successful operation.
* @throws ApiError
*/
static listSecurityRepositories(provider, remoteOrganizationName, cursor, limit = 100, segments, abortSignal) {
return __request(OpenAPI, {
method: 'GET',
url: '/organizations/{provider}/{remoteOrganizationName}/security/repositories',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
},
query: {
'cursor': cursor,
'limit': limit,
'segments': segments,
},
abortSignal,
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
/**
* Return a list of security subcategories that have security issues.
* @param provider Git provider* @param remoteOrganizationName Organization name on the Git provider* @param cursor Cursor to [specify a batch of results to request](https://docs.codacy.com/codacy-api/using-the-codacy-api/#using-pagination)* @param limit Maximum number of items to return * @returns SecurityCategoriesResponse Successful operation.
* @throws ApiError
*/
static listSecurityCategories(provider, remoteOrganizationName, cursor, limit = 100, abortSignal) {
return __request(OpenAPI, {
method: 'GET',
url: '/organizations/{provider}/{remoteOrganizationName}/security/categories',
path: {
'provider': provider,
'remoteOrganizationName': remoteOrganizationName,
},
query: {
'cursor': cursor,
'limit': limit,
},
abortSignal,
errors: {
400: `Bad Request`,
401: `Unauthorized`,
403: `Forbidden`,
404: `Not Found`,
500: `Internal Server Error`,
},
});
}
}