Skip to content

Commit

Permalink
refactor: minor renames
Browse files Browse the repository at this point in the history
  • Loading branch information
mziyabo committed Apr 7, 2024
1 parent 653f472 commit b699374
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "trivy-argocd-component",
"name": "argocd-trivy-extension",
"version": "0.1.0",
"private": true,
"dependencies": {
Expand All @@ -9,10 +9,14 @@
"axios": "1.6.8",
"gridjs": "^6.2.0",
"gridjs-react": "^6.1.1",
"recharts": "^2.12.3"
},
"peerDependencies": {
"argo-ui": "git+https://github.com/argoproj/argo-ui.git",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "^5.0.1",
"recharts": "^2.12.3"
"moment": "^2.29.4"
},
"browser": {
"fs": false,
Expand All @@ -21,9 +25,7 @@
},
"scripts": {
"start": "react-scripts start",
"build": "webpack --config ./webpack.config.js && tar -C dist -cvf ./dist/resources/extension-Trivy.tar resources",
"test": "react-scripts test",
"eject": "react-scripts eject"
"build": "webpack --config ./webpack.config.js && tar -C dist -cvf ./dist/resources/extension-trivy.tar resources"
},
"eslintConfig": {
"extends": [
Expand Down Expand Up @@ -54,4 +56,4 @@
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.2"
}
}
}
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function App() {
return (
<React.Fragment>
<Tabs value={currentTabIndex} onChange={handleTabChange}>
<Tab label='Table' />
<Tab label='Table'/>
<Tab label='Dashboard'/>
</Tabs>
{currentTabIndex === 0 && (
Expand Down
8 changes: 3 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState } from 'react';
import ReactDOM from 'react-dom/client';
// import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
// import App from './App';
import { Tab, Tabs } from "@mui/material";
import DataGrid from './components/grid/vulnerability-report';
import Dashboard from './components/dashboard/dashboard';
Expand All @@ -18,13 +18,12 @@ const Extension = (props) => {

const { resource, application } = props;
const appName = application?.metadata?.name || "";

let container = resource?.spec?.template?.spec?.containers[0]?.name || "";
let resourceName = resource?.metadata?.name || "";
let resourceNamespace = resource?.metadata?.namespace || "";

let resourceKind = resource?.kind?.toLowerCase() || "";


if (resource?.kind === "Pod") {
container = resource?.spec?.containers[0]?.name
resourceName = resource?.metadata?.ownerReferences[0].name.toLowerCase()
Expand Down Expand Up @@ -57,7 +56,6 @@ const Extension = (props) => {

const component = Extension;

// Register the component extension in ArgoCD
((window) => {
window?.extensionsAPI?.registerResourceExtension(
component,
Expand Down
9 changes: 4 additions & 5 deletions src/utils/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,15 @@ export async function GridData(reportUrl) {
export async function DashboardData(reportUrl) {
vulnerabilityData = await GetVulnerabilityData(reportUrl);

// TODO: refactor names
if (vulnerabilityData.length === 0) {
return {
novulnerabilitydata: true
noVulnerabilityData: true
}
}

return {
severityCounts: severityCountData(),
fixedToUnfixedData: fixedToUnfixedData(),
severityData: severityCountData(),
patchSummaryData: patchSummaryData(),
topVulnerableResourcesData: topVulnerableResourcesData(15),
vulnerabilityAgeDistribution: vulnerabilityAgeDistribution(),
vulnerabilitiesByType: vulnerabilitiesByType()
Expand All @@ -71,7 +70,7 @@ function severityCountData() {
return data;
}

function fixedToUnfixedData() {
function patchSummaryData() {
const count = (severity, fixed = true) => {
return vulnerabilityData.filter(v => (fixed ? v.fixedVersion !== "" : v.fixedVersion === "")
&& v.severity === severity).length
Expand Down

0 comments on commit b699374

Please sign in to comment.