Skip to content

Commit

Permalink
Merge pull request #6 from sysdiglabs/dev-proxy-endpoints
Browse files Browse the repository at this point in the history
Abstract proxy endpoint paths
  • Loading branch information
Jujuyeh authored Mar 6, 2024
2 parents 1c2c5a7 + c38ab37 commit 52ab603
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ import {
getGauge,
getScope,
getResourceName,
getTitleWithBacklink
getTitleWithBacklink,

API_PROXY_BASE_PATH,
API_INVENTORY,
BACKLINK_INVENTORY
} from '../../lib'


Expand Down Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ import {
// methods
getStatusColorSpan,
getTitleWithBacklink,
getChips
getChips,

API_PROXY_BASE_PATH,
API_VULN_PIPELINE,
BACKLINK_VULN_PIPELINE
} from '../../lib'

type PipelineScan = {
Expand Down Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ import {

// methods
getChips,
getTitleWithBacklink
getTitleWithBacklink,

API_PROXY_BASE_PATH,
API_VULN_REGISTRY,
BACKLINK_VULN_REGISTRY
} from '../../lib'


Expand Down Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ import {
getStatusColorSpan,
getChips,
getDetails,
getTitleWithBacklink
getTitleWithBacklink,

API_PROXY_BASE_PATH,
API_VULN_RUNTIME,
BACKLINK_VULN_RUNTIME
} from '../../lib'


Expand Down Expand Up @@ -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;

Expand Down
36 changes: 36 additions & 0 deletions src/lib/endpoints.ts
Original file line number Diff line number Diff line change
@@ -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";
14 changes: 13 additions & 1 deletion src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,16 @@ export {
getResourceName,
getTitleWithBacklink,
urlEncode
} from './ui'
} 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'

0 comments on commit 52ab603

Please sign in to comment.