Skip to content

Commit b3ebe49

Browse files
committed
first release
1 parent 77a9c44 commit b3ebe49

32 files changed

+2086
-2
lines changed

.DS_Store

6 KB
Binary file not shown.

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname);

.gitignore

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
.pnpm-debug.log*
9+
10+
# Diagnostic reports (https://nodejs.org/api/report.html)
11+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
12+
13+
# Runtime data
14+
pids
15+
*.pid
16+
*.seed
17+
*.pid.lock
18+
19+
# Directory for instrumented libs generated by jscoverage/JSCover
20+
lib-cov
21+
22+
# Coverage directory used by tools like istanbul
23+
coverage
24+
*.lcov
25+
26+
# nyc test coverage
27+
.nyc_output
28+
29+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
30+
.grunt
31+
32+
# Bower dependency directory (https://bower.io/)
33+
bower_components
34+
35+
# node-waf configuration
36+
.lock-wscript
37+
38+
# Compiled binary addons (https://nodejs.org/api/addons.html)
39+
build/Release
40+
41+
# Dependency directories
42+
node_modules/
43+
jspm_packages/
44+
45+
# Snowpack dependency directory (https://snowpack.dev/)
46+
web_modules/
47+
48+
# TypeScript cache
49+
*.tsbuildinfo
50+
51+
# Optional npm cache directory
52+
.npm
53+
54+
# Optional eslint cache
55+
.eslintcache
56+
57+
# Optional stylelint cache
58+
.stylelintcache
59+
60+
# Microbundle cache
61+
.rpt2_cache/
62+
.rts2_cache_cjs/
63+
.rts2_cache_es/
64+
.rts2_cache_umd/
65+
66+
# Optional REPL history
67+
.node_repl_history
68+
69+
# Output of 'npm pack'
70+
*.tgz
71+
72+
# Yarn Integrity file
73+
.yarn-integrity
74+
75+
# dotenv environment variable files
76+
.env
77+
.env.development.local
78+
.env.test.local
79+
.env.production.local
80+
.env.local
81+
82+
# parcel-bundler cache (https://parceljs.org/)
83+
.cache
84+
.parcel-cache
85+
86+
# Next.js build output
87+
.next
88+
out
89+
90+
# Nuxt.js build / generate output
91+
.nuxt
92+
dist
93+
94+
# Gatsby files
95+
.cache/
96+
# Comment in the public line in if your project uses Gatsby and not Next.js
97+
# https://nextjs.org/blog/next-9-1#public-directory-support
98+
# public
99+
100+
# vuepress build output
101+
.vuepress/dist
102+
103+
# vuepress v2.x temp and cache directory
104+
.temp
105+
.cache
106+
107+
# Docusaurus cache and generated files
108+
.docusaurus
109+
110+
# Serverless directories
111+
.serverless/
112+
113+
# FuseBox cache
114+
.fusebox/
115+
116+
# DynamoDB Local files
117+
.dynamodb/
118+
119+
# TernJS port file
120+
.tern-port
121+
122+
# Stores VSCode versions used for testing VSCode extensions
123+
.vscode-test
124+
125+
# yarn v2
126+
.yarn/cache
127+
.yarn/unplugged
128+
.yarn/build-state.yml
129+
.yarn/install-state.gz
130+
.pnp.*
131+
yarn.lock
132+
133+
# tsc
134+
dist-types/

README.md

Lines changed: 118 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,118 @@
1-
# backstage-plugin-sysdig
2-
Backstage Sysdig Plugin
1+
# Sysdig Plugin for Backstage
2+
3+
4+
Welcome to the official Sysdig Plugin for Backstage. This plugin will show you the latest Vulnerabilities and Posture reports of your services using Sysdig Secure.
5+
6+
![Example](img/example1.png)
7+
![Example](img/example2.png)
8+
9+
## Pre-requisites
10+
11+
For this plugin to work, you will access to Sysdig Secure.
12+
13+
You must provide:
14+
15+
- Your **Sysdig Secure API Key**.
16+
- Your **Sysdig Secure Endpoint** (region for SaS).
17+
18+
Please refer to the [official documentation](https://docs.sysdig.com/en/docs/administration/saas-regions-and-ip-ranges/) for more details.
19+
20+
## Getting started
21+
22+
23+
### Install the package
24+
25+
```bash
26+
# From your Backstage root directory
27+
yarn --cwd packages/app add @sysdig/backstage-plugin-sysdig
28+
```
29+
30+
### Add the route
31+
32+
Add the **Sysdig page** to the Entity routes in `packages/app/src/components/catalog/EntityPage.tsx`:
33+
34+
```diff
35+
+ import { SysdigPage } from '@sysdig/backstage-plugin-sysdig';
36+
37+
...
38+
39+
40+
const serviceEntityPage = (
41+
<EntityLayoutWrapper>
42+
43+
...
44+
45+
+ <EntityLayout.Route path="/sysdig" title="Sysdig">
46+
+ <SysdigPage />
47+
+ </EntityLayout.Route>
48+
49+
...
50+
51+
</EntityPageLayout>
52+
)
53+
```
54+
55+
### Add the Sysdig connection settings
56+
57+
Edit `app-config.yaml` and add to the API endpoints the following details:
58+
59+
```diff
60+
proxy:
61+
endpoints:
62+
+ '/sysdig':
63+
+ target: 'https://secure.sysdig.com/'
64+
+ changeOrigin: true
65+
+ allowedMethods: ['GET']
66+
+ headers:
67+
+ "Authorization": "Bearer ${SYSDIG_SECURE_TOKEN}"
68+
+ "Content-Type": "application/json"
69+
+ "Accept": "application/json"
70+
+ "X-Sysdig-Product": "SDS"
71+
```
72+
73+
Replace the value for `target` with your Sysdig Secure Endpoint.
74+
75+
You can replace `${SYSDIG_SECURE_TOKEN}` with your Sysdig Secure API Token, or you can set it to the `SYSDIG_SECURE_TOKEN` environment variable when deploying your Backstage instance.
76+
77+
78+
## How to annotate services
79+
80+
All added annotations are available and documented in the [source file](./src/lib/annotations.ts).
81+
82+
Be aware that not all annotations are needed, the different reports may or may not work depending on which information is provided. For example, to get Registry scanning results, you will need to annotate the corresponding services with registry data.
83+
84+
### Example
85+
86+
```yaml
87+
apiVersion: backstage.io/v1alpha1
88+
kind: Component
89+
metadata:
90+
name: sock-shop-carts
91+
annotations:
92+
# VM Runtime
93+
sysdigcloud.com/kubernetes-cluster-name: sock-shop-cluster
94+
sysdigcloud.com/kubernetes-namespace-name: sock-shop
95+
sysdigcloud.com/kubernetes-workload-name: sock-shop-carts
96+
sysdigcloud.com/kubernetes-workload-type: deployment
97+
98+
# VM Registry
99+
sysdigcloud.com/registry-vendor: harbor
100+
sysdigcloud.com/registry-name: registry-harbor-registry.registry.svc.cluster.local:5443
101+
102+
# VM Pipeline
103+
sysdigcloud.com/image-freetext: ghcr.io/sysdiglabs
104+
105+
# Posture
106+
sysdigcloud.com/resource-name: sock-shop-carts
107+
sysdigcloud.com/resource-type: "Deployment"
108+
description: |
109+
This is the Sock shop service that keeps track of socks pairs to be purchased.
110+
spec:
111+
type: service
112+
lifecycle: experimental
113+
owner: team-c
114+
system: sock-shop
115+
dependsOn:
116+
- component:default/sock-shop-carts-db
117+
118+
```

dev/index.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright 2023 The Backstage Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
import React from 'react';
17+
import { createDevApp } from '@backstage/dev-utils';
18+
import { sysdigPlugin, SysdigPage } from '../src/plugin';
19+
20+
createDevApp()
21+
.registerPlugin(sysdigPlugin)
22+
.addPage({
23+
element: <SysdigPage />,
24+
title: 'Root Page',
25+
path: '/sysdig'
26+
})
27+
.render();

img/example1.png

696 KB
Loading

img/example2.png

658 KB
Loading

package.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"name": "@sysdig/backstage-plugin-sysdig",
3+
"version": "0.0.0",
4+
"main": "src/index.ts",
5+
"types": "src/index.ts",
6+
"license": "Apache-2.0",
7+
"publishConfig": {
8+
"access": "public",
9+
"main": "dist/index.esm.js",
10+
"types": "dist/index.d.ts"
11+
},
12+
"backstage": {
13+
"role": "frontend-plugin"
14+
},
15+
"sideEffects": false,
16+
"scripts": {
17+
"start": "backstage-cli package start",
18+
"build": "backstage-cli package build",
19+
"lint": "backstage-cli package lint",
20+
"test": "backstage-cli package test",
21+
"clean": "backstage-cli package clean",
22+
"prepack": "backstage-cli package prepack",
23+
"postpack": "backstage-cli package postpack"
24+
},
25+
"dependencies": {
26+
"@backstage/core-components": "workspace:^",
27+
"@backstage/core-plugin-api": "workspace:^",
28+
"@backstage/theme": "workspace:^",
29+
"@material-ui/core": "^4.9.13",
30+
"@material-ui/icons": "^4.9.1",
31+
"@material-ui/lab": "^4.0.0-alpha.61",
32+
"react-use": "^17.2.4"
33+
},
34+
"peerDependencies": {
35+
"react": "^16.13.1 || ^17.0.0"
36+
},
37+
"devDependencies": {
38+
"@backstage/cli": "workspace:^",
39+
"@backstage/core-app-api": "workspace:^",
40+
"@backstage/dev-utils": "workspace:^",
41+
"@backstage/test-utils": "workspace:^",
42+
"@testing-library/jest-dom": "^5.10.1",
43+
"@testing-library/react": "^12.1.3",
44+
"@testing-library/user-event": "^14.0.0",
45+
"msw": "^1.0.0"
46+
},
47+
"files": [
48+
"dist"
49+
]
50+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2023 The Backstage Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
import React from 'react';
17+
import { SysdigComponent } from './SysdigComponent';
18+
import { rest } from 'msw';
19+
import { setupServer } from 'msw/node';
20+
import { screen } from '@testing-library/react';
21+
import {
22+
setupRequestMockHandlers,
23+
renderInTestApp,
24+
} from "@backstage/test-utils";
25+
26+
describe('SysdigComponent', () => {
27+
const server = setupServer();
28+
// Enable sane handlers for network requests
29+
setupRequestMockHandlers(server);
30+
31+
// setup mock response
32+
beforeEach(() => {
33+
server.use(
34+
rest.get('/*', (_, res, ctx) => res(ctx.status(200), ctx.json({}))),
35+
);
36+
});
37+
38+
it('should render', async () => {
39+
await renderInTestApp(<SysdigComponent />);
40+
expect(screen.getByText('Welcome to sysdig!')).toBeInTheDocument();
41+
});
42+
});

0 commit comments

Comments
 (0)