diff --git a/package.json b/package.json index efe0cfe..d5ead93 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@sysdig/backstage-plugin-sysdig", - "version": "1.0.0", + "version": "1.1.0", "main": "dist/index.esm.js", "types": "dist/index.d.ts", "license": "Apache-2.0", diff --git a/src/components/SysdigPostureFetchComponent/SysdigPostureFetchComponent.tsx b/src/components/SysdigPostureFetchComponent/SysdigPostureFetchComponent.tsx index 7a43a52..98877bb 100644 --- a/src/components/SysdigPostureFetchComponent/SysdigPostureFetchComponent.tsx +++ b/src/components/SysdigPostureFetchComponent/SysdigPostureFetchComponent.tsx @@ -55,7 +55,11 @@ import { getGauge, getScope, getResourceName, - getTitleWithBacklink + getTitleWithBacklink, + + API_PROXY_BASE_PATH, + API_INVENTORY, + BACKLINK_INVENTORY } from '../../lib' @@ -208,11 +212,11 @@ export const DenseTable = ({ postureScans, title }: DenseTableProps) => { export const SysdigPostureFetchComponent = () => { const { entity } = useEntity(); const backendUrl = useApi(configApiRef).getString('backend.baseUrl'); - var backlink = useApi(configApiRef).getString('sysdig.endpoint') + '#/inventory'; + var backlink = useApi(configApiRef).getString('sysdig.endpoint') + BACKLINK_INVENTORY; const annotations = entity.metadata.annotations; - let uri = backendUrl + '/api/proxy/sysdig/api/cspm/v1/inventory/resources'; + let uri = backendUrl + API_PROXY_BASE_PATH + API_INVENTORY; let filter = '?filter='; var name; diff --git a/src/components/SysdigVMPipelineFetchComponent/SysdigVMPipelineFetchComponent.tsx b/src/components/SysdigVMPipelineFetchComponent/SysdigVMPipelineFetchComponent.tsx index 4196eef..d07e6dd 100644 --- a/src/components/SysdigVMPipelineFetchComponent/SysdigVMPipelineFetchComponent.tsx +++ b/src/components/SysdigVMPipelineFetchComponent/SysdigVMPipelineFetchComponent.tsx @@ -27,7 +27,11 @@ import { // methods getStatusColorSpan, getTitleWithBacklink, - getChips + getChips, + + API_PROXY_BASE_PATH, + API_VULN_PIPELINE, + BACKLINK_VULN_PIPELINE } from '../../lib' type PipelineScan = { @@ -110,9 +114,9 @@ export const DenseTable = ({ pipelineScans, title }: DenseTableProps) => { export const SysdigVMPipelineFetchComponent = () => { const { entity } = useEntity(); const backendUrl = useApi(configApiRef).getString('backend.baseUrl'); - var backlink = useApi(configApiRef).getString('sysdig.endpoint') + '#/vulnerabilities/pipeline/'; + var backlink = useApi(configApiRef).getString('sysdig.endpoint') + BACKLINK_VULN_PIPELINE; - let uri = backendUrl + '/api/proxy/sysdig/secure/vulnerability/v1beta1/pipeline-results'; + let uri = backendUrl + API_PROXY_BASE_PATH + API_VULN_PIPELINE; let filter = '?filter='; var name; diff --git a/src/components/SysdigVMRegistryFetchComponent/SysdigVMRegistryFetchComponent.tsx b/src/components/SysdigVMRegistryFetchComponent/SysdigVMRegistryFetchComponent.tsx index d4328c9..44acfe3 100644 --- a/src/components/SysdigVMRegistryFetchComponent/SysdigVMRegistryFetchComponent.tsx +++ b/src/components/SysdigVMRegistryFetchComponent/SysdigVMRegistryFetchComponent.tsx @@ -27,7 +27,11 @@ import { // methods getChips, - getTitleWithBacklink + getTitleWithBacklink, + + API_PROXY_BASE_PATH, + API_VULN_REGISTRY, + BACKLINK_VULN_REGISTRY } from '../../lib' @@ -99,9 +103,9 @@ export const DenseTable = ({ registryScans, title }: DenseTableProps) => { export const SysdigVMRegistryFetchComponent = () => { const { entity } = useEntity(); const backendUrl = useApi(configApiRef).getString('backend.baseUrl'); - var backlink = useApi(configApiRef).getString('sysdig.endpoint') + '#/vulnerabilities/registry/'; + var backlink = useApi(configApiRef).getString('sysdig.endpoint') + BACKLINK_VULN_REGISTRY; - let uri = backendUrl + '/api/proxy/sysdig/secure/vulnerability/v1beta1/registry-results'; + let uri = backendUrl + API_PROXY_BASE_PATH + API_VULN_REGISTRY; let filter = '?filter='; var name; diff --git a/src/components/SysdigVMRuntimeFetchComponent/SysdigVMRuntimeFetchComponent.tsx b/src/components/SysdigVMRuntimeFetchComponent/SysdigVMRuntimeFetchComponent.tsx index 8aec5f3..f343ac0 100644 --- a/src/components/SysdigVMRuntimeFetchComponent/SysdigVMRuntimeFetchComponent.tsx +++ b/src/components/SysdigVMRuntimeFetchComponent/SysdigVMRuntimeFetchComponent.tsx @@ -33,7 +33,11 @@ import { getStatusColorSpan, getChips, getDetails, - getTitleWithBacklink + getTitleWithBacklink, + + API_PROXY_BASE_PATH, + API_VULN_RUNTIME, + BACKLINK_VULN_RUNTIME } from '../../lib' @@ -150,9 +154,9 @@ export const DenseTable = ({ runtimeScans, title }: DenseTableProps) => { export const SysdigVMRuntimeFetchComponent = () => { const { entity } = useEntity(); const backendUrl = useApi(configApiRef).getString('backend.baseUrl'); - var backlink = useApi(configApiRef).getString('sysdig.endpoint') + '#/vulnerabilities/runtime/'; + var backlink = useApi(configApiRef).getString('sysdig.endpoint') + BACKLINK_VULN_RUNTIME; - let uri = backendUrl + '/api/proxy/sysdig/secure/vulnerability/v1beta1/runtime-results'; + let uri = backendUrl + API_PROXY_BASE_PATH + API_VULN_RUNTIME; let filter = '?filter='; var name; diff --git a/src/lib/endpoints.ts b/src/lib/endpoints.ts new file mode 100644 index 0000000..0b94701 --- /dev/null +++ b/src/lib/endpoints.ts @@ -0,0 +1,36 @@ +/* Sysdig Endpoints */ + +// Proxy path to Sysdig's endpoint. Edit this if using a custom proxy ;) +export const API_PROXY_BASE_PATH = "/api/proxy/sysdig"; + +/* + * API paths for Sysdig results + */ + +// API Endpoint for Vulnerability Management at Runtime +export const API_VULN_RUNTIME = "/secure/vulnerability/v1beta1/runtime-results"; + +// API Endpoint for Vulnerability Management at Registry +export const API_VULN_REGISTRY = "/secure/vulnerability/v1beta1/registry-results"; + +// API Endpoint for Vulnerability Management at Pipeline +export const API_VULN_PIPELINE = "/secure/vulnerability/v1beta1/pipeline-results"; + +// API Endpoint for Inventory (Posture) +export const API_INVENTORY = "/api/cspm/v1/inventory/resources"; + +/* + * Backlink paths to product + */ + +// Backlink path to Vulnerability Management at Runtime +export const BACKLINK_VULN_RUNTIME = "#/vulnerabilities/runtime/"; + +// Backlink path to Vulnerability Management at Registry +export const BACKLINK_VULN_REGISTRY = "#/vulnerabilities/registry/"; + +// Backlink path to Vulnerability Management at Pipeline +export const BACKLINK_VULN_PIPELINE = "#/vulnerabilities/pipeline/"; + +// Backlink path to Inventory +export const BACKLINK_INVENTORY = "#/inventory"; \ No newline at end of file diff --git a/src/lib/index.ts b/src/lib/index.ts index 128452e..2887b07 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -45,4 +45,16 @@ export { getResourceName, getTitleWithBacklink, urlEncode -} from './ui' \ No newline at end of file +} from './ui' + +export { + API_PROXY_BASE_PATH, + API_VULN_RUNTIME, + API_VULN_REGISTRY, + API_VULN_PIPELINE, + API_INVENTORY, + BACKLINK_VULN_RUNTIME, + BACKLINK_VULN_REGISTRY, + BACKLINK_VULN_PIPELINE, + BACKLINK_INVENTORY +} from './endpoints' \ No newline at end of file