Skip to content

Commit

Permalink
fix: fixed vulnerablities and migrated away from old argo-ui package (#…
Browse files Browse the repository at this point in the history
…4497)

Signed-off-by: Sahil <sahil.kumar@harness.io>
  • Loading branch information
SahilKr24 authored Mar 7, 2024
1 parent c73ad1c commit dc5c36a
Show file tree
Hide file tree
Showing 10 changed files with 1,981 additions and 2,468 deletions.
25 changes: 7 additions & 18 deletions chaoscenter/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,10 @@
"@tanstack/react-query": "4.20.4",
"@types/d3-array": "^3.0.3",
"@types/react-timeago": "^4.1.3",
"@visx/axis": "^2.10.0",
"@visx/brush": "^2.10.1",
"@visx/curve": "^2.1.0",
"@visx/gradient": "^2.10.0",
"@visx/grid": "^2.10.0",
"@visx/group": "^2.10.0",
"@visx/mock-data": "^2.1.2",
"@visx/pattern": "^2.10.0",
"@visx/responsive": "^2.10.0",
"@visx/scale": "^2.2.2",
"@visx/shape": "^2.10.0",
"@visx/xychart": "1.7.2",
"@visx/visx": "^2.18.0",
"ajv": "^8.12.0",
"anser": "2.0.1",
"argo-ui": "https://github.com/argoproj/argo-ui.git#v2.5.0",
"axios": "^0.26.1",
"axios": "^0.28.0",
"classnames": "^2.2.6",
"clipboard-copy": "^3.1.0",
"cron-parser": "^4.6.0",
Expand Down Expand Up @@ -142,9 +130,9 @@
"@typescript-eslint/parser": "^5.22.0",
"circular-dependency-plugin": "^5.2.2",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.4.0",
"css-loader": "^6.10.0",
"dotenv": "^10.0.0",
"eslint": "^7.32.0",
"eslint": "^7.6.0",
"eslint-config-prettier": "^8.3.0",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-import-resolver-typescript": "^2.5.0",
Expand Down Expand Up @@ -177,7 +165,7 @@
"vscode-languageserver-types": "^3.17.1",
"webpack": "^5.58.0",
"webpack-cli": "^4.9.0",
"webpack-dev-server": "^4.3.1",
"webpack-dev-server": "^4.15.1",
"webpack-merge": "^5.9.0",
"webpack-retry-chunk-load-plugin": "^3.1.1",
"yaml-jest": "^1.2.0",
Expand All @@ -187,6 +175,7 @@
"@types/react": "^17.0.27",
"@types/react-dom": "^17.0.9",
"create-react-context": "0.3.0",
"@blueprintjs/core": "3.26.1"
"@blueprintjs/core": "3.26.1",
"d3-color": "3.1.0"
}
}
15 changes: 7 additions & 8 deletions chaoscenter/web/src/models/chaosEngine.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type * as kubernetes from 'argo-ui/src/models/kubernetes';
import type { ConfigMap, Secret, Toleration } from './k8s';
import type * as kubernetes from './k8s';

// ChaosEngine is the Schema for the chaosengines API
export interface ChaosEngine {
Expand Down Expand Up @@ -100,11 +99,11 @@ export interface RunnerInfo {
// NodeSelector for runner pod
nodeSelector?: { [key: string]: string };
// ConfigMaps for runner pod
configMaps?: ConfigMap[];
configMaps?: kubernetes.ConfigMap[];
// Secrets for runner pod
secrets?: Secret[];
secrets?: kubernetes.Secret[];
// Tolerations for runner pod
tolerations?: Toleration;
tolerations?: kubernetes.Toleration;
// Resource requirements for the runner pod
resources?: kubernetes.ResourceRequirements;
}
Expand Down Expand Up @@ -334,15 +333,15 @@ export interface RunProperty {
// FaultComponents contains ENV, Configmaps and Secrets
export interface FaultComponents {
env?: kubernetes.EnvVar[];
configMaps?: ConfigMap;
secrets?: Secret;
configMaps?: kubernetes.ConfigMap;
secrets?: kubernetes.Secret;
experimentAnnotations?: { [key: string]: string };
experimentImage?: string;
experimentImagePullSecrets?: kubernetes.LocalObjectReference[];
nodeSelector?: { [key: string]: string };
statusCheckTimeouts?: StatusCheckTimeout;
resources?: kubernetes.ResourceRequirements;
tolerations?: Toleration;
tolerations?: kubernetes.Toleration;
}

// StatusCheckTimeout contains Delay and timeouts for the status checks
Expand Down
11 changes: 5 additions & 6 deletions chaoscenter/web/src/models/chaosFaults.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type * as kubernetes from 'argo-ui/src/models/kubernetes';
import type { ConfigMap, HostFile, PolicyRule, Secret } from './k8s';
import type * as kubernetes from './k8s';

// ChaosExperiment is the Schema for the chaosexperiments API
export interface ChaosExperiment {
Expand Down Expand Up @@ -35,19 +34,19 @@ export interface FaultDef {
//Scope specifies the service account scope (& thereby blast radius) of the experiment
scope: string;
// List of Permission needed for a service account to execute experiment
permissions: PolicyRule[];
permissions: kubernetes.PolicyRule[];
// List of ENV vars passed to executor pod
env?: kubernetes.EnvVar[];
// Defines command to invoke experiment
command: string[];
// Defines arguments to runner's entrypoint command
args: string[];
// ConfigMaps contains a list of ConfigMaps
configMaps?: ConfigMap[];
configMaps?: kubernetes.ConfigMap[];
// Secrets contains a list of Secrets
secrets?: Secret[];
secrets?: kubernetes.Secret[];
// HostFileVolume defines the host directory/file to be mounted
hostFileVolumes?: HostFile;
hostFileVolumes?: kubernetes.HostFile;
// Annotations that needs to be provided in the pod for pod that is getting created
experimentAnnotations: { [key: string]: string };
// SecurityContext holds security configuration that will be applied to a container
Expand Down
2 changes: 1 addition & 1 deletion chaoscenter/web/src/models/chaosResult.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type * as kubernetes from 'argo-ui/src/models/kubernetes';
import type * as kubernetes from './k8s';

// ChaosResult is the Schema for the chaosresults API
export interface ChaosResult {
Expand Down
2 changes: 1 addition & 1 deletion chaoscenter/web/src/models/cronWorkflows.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type * as kubernetes from 'argo-ui/src/models/kubernetes';
import type * as kubernetes from './k8s';
import type { Condition, WorkflowSpec } from './workflows';

export interface CronWorkflow {
Expand Down
159 changes: 157 additions & 2 deletions chaoscenter/web/src/models/k8s.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,126 @@
/*
* Copyright 2022 Harness Inc. All rights reserved.
* Use of this source code is governed by the PolyForm Shield 1.0.0 license
* that can be found in the licenses directory at the root of this repository, also available at
* https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt.
*/

/* eslint-disable @typescript-eslint/no-explicit-any */
export type Toleration = any;
export type Time = string;
export type VolumeDevice = any;
export type Volume = any;
export type EnvFromSource = any;
export type EnvVarSource = any;
export type ResourceRequirements = any;
export type VolumeMount = any;
export type Probe = any;
export type Lifecycle = any;
export type TerminationMessagePolicy = any;
export type PullPolicy = any;
export type PersistentVolumeClaim = any;
export type Affinity = any;
export type PodSecurityContext = any;
export type HostPathType = any;
export type SecurityContext = any;

export interface Toleration {
tolerationSeconds?: number;
key?: string;
operator?: string;
effect?: string;
value?: string;
}

export interface ListMeta {
continue?: string;
resourceVersion?: string;
selfLink?: string;
}

export interface ObjectMeta {
name?: string;
generateName?: string;
namespace?: string;
selfLink?: string;
uid?: string;
resourceVersion?: string;
generation?: number;
creationTimestamp?: Time;
deletionTimestamp?: Time;
deletionGracePeriodSeconds?: number;
labels?: { [name: string]: string };
annotations?: { [name: string]: string };
ownerReferences?: any[];
initializers?: any;
finalizers?: string[];
clusterName?: string;
}

export interface TypeMeta {
kind?: string;
apiVersion?: string;
}

export interface LocalObjectReference {
name?: string;
}

export interface ObjectReference {
kind?: string;
namespace?: string;
name?: string;
uid?: string;
apiVersion?: string;
resourceVersion?: string;
fieldPath?: string;
}

export interface SecretKeySelector extends LocalObjectReference {
key: string;
optional: boolean;
}

export interface ContainerPort {
name?: string;
hostPort?: number;
containerPort: number;
protocol?: string;
hostIP?: string;
}

export interface EnvVar {
name: string;
value?: string;
valueFrom?: EnvVarSource;
}

export interface Container {
name: string;
image?: string;
command?: string[];
args?: string[];
workingDir?: string;
ports?: ContainerPort[];
envFrom?: EnvFromSource[];
env?: EnvVar[];
resources?: ResourceRequirements;
volumeMounts?: VolumeMount[];
livenessProbe?: Probe;
readinessProbe?: Probe;
lifecycle?: Lifecycle;
terminationMessagePath?: string;
terminationMessagePolicy?: TerminationMessagePolicy;
imagePullPolicy?: PullPolicy;
securityContext?: SecurityContext;
stdin?: boolean;
stdinOnce?: boolean;
tty?: boolean;
}

export interface WatchEvent<T> {
object: T;
type: 'ADDED' | 'MODIFIED' | 'DELETED' | 'ERROR';
}

export interface ConfigMap {
data?: { [key: string]: string };
Expand All @@ -24,5 +145,39 @@ export interface HostFile {
name: string;
mountPath: string;
nodePath: string;
type?: string;
type?: HostPathType;
}

// SourceDetails contains source details of the cmdProbe
export interface SourceDetails {
// Image for the source pod
image?: string;
// HostNetwork define the hostNetwork of the external pod
// it supports boolean values and default value is false
hostNetwork?: boolean;
// InheritInputs defined to inherit experiment pod attributes(ENV, volumes, and volumeMounts) into probe pod
// it supports boolean values and default value is false
inheritInputs?: boolean;
// Args for the source pod
args?: string[];
// ENVList contains ENV passed to the source pod
env?: EnvVar[];
// Labels for the source pod
labels?: { [key: string]: string };
// Annotations for the source pod
annotations?: { [key: string]: string };
// Command for the source pod
command?: string[];
// ImagePullPolicy for the source pod
imagePullPolicy?: PullPolicy;
//ImagePullSecrets for runner pod
imagePullSecrets?: LocalObjectReference[];
// Privileged for the source pod
privileged?: boolean;
// NodeSelector for the source pod
nodeSelector?: { [key: string]: string };
// Volumes for the source pod
volumes?: Volume;
// VolumesMount for the source pod
volumesMount?: VolumeMount;
}
2 changes: 1 addition & 1 deletion chaoscenter/web/src/models/workflows.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable */
// These models come from argo, hence disabling eslint
import type * as kubernetes from 'argo-ui/src/models/kubernetes';
import type * as kubernetes from './k8s';

export const labels = {
clusterWorkflowTemplate: 'workflows.argoproj.io/cluster-workflow-template',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { parse } from 'yaml';
import type { EnvVar } from 'argo-ui/src/models/kubernetes';
import { ChaosObjectStoreNameMap, ChaosObjectStoresPrimaryKeys, Experiment } from '@db';
import {
ChaosEngine,
Expand All @@ -19,6 +18,7 @@ import {
import { yamlStringify } from '@utils';
import { Weightages, InfrastructureType, ProbeObj } from '@api/entities';
import type { PipelineGraphState } from '@components/PipelineDiagram/types';
import { EnvVar } from 'models/k8s';
import ExperimentFactory from './ExperimentFactory';
import { ExperimentYamlService, GetFaultTunablesOperation, PreProcessChaosExperiment } from './ExperimentYamlService';

Expand Down
1 change: 0 additions & 1 deletion chaoscenter/web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"experimentalDecorators": true,
"typeRoots": ["node_modules/@types", "./typings"],
"resolveJsonModule": true,
"importsNotUsedAsValues": "error",
"noUnusedLocals": true,
"noUnusedParameters": true
},
Expand Down
Loading

0 comments on commit dc5c36a

Please sign in to comment.