From 35a39993c2fb5f897a4d73ba49ece0b21329fd23 Mon Sep 17 00:00:00 2001 From: Delnat Wito Date: Thu, 7 Sep 2023 14:25:48 +0200 Subject: [PATCH] fix: fixup --- .../ValidationOverview/ProblemRenderer.tsx | 12 ++++++++++++ packages/validation/src/MonokleValidator.ts | 19 +++++++++---------- ...MonokleValidator.kubernetes-schema.test.ts | 2 +- .../MonokleValidator.metadata.test.ts | 2 +- .../__tests__/MonokleValidator.pss.test.ts | 2 +- .../src/__tests__/MonokleValidator.test.ts | 2 +- .../src/pluginLoaders/PluginLoader.ts | 2 +- 7 files changed, 26 insertions(+), 15 deletions(-) diff --git a/packages/components/src/molecules/ValidationOverview/ProblemRenderer.tsx b/packages/components/src/molecules/ValidationOverview/ProblemRenderer.tsx index 98c38c33b..a6a16d859 100644 --- a/packages/components/src/molecules/ValidationOverview/ProblemRenderer.tsx +++ b/packages/components/src/molecules/ValidationOverview/ProblemRenderer.tsx @@ -87,6 +87,18 @@ const ProblemRenderer: React.FC = props => { )} + + + { + node.problem.locations[groupByFilterValue === 'group-by-file' ? 0 : 1].physicalLocation?.region + ?.startLine + } + + + {node.problem.message.text} {suppressed ? '(suppressed)' : ''} diff --git a/packages/validation/src/MonokleValidator.ts b/packages/validation/src/MonokleValidator.ts index 11b11fa06..4636aef51 100644 --- a/packages/validation/src/MonokleValidator.ts +++ b/packages/validation/src/MonokleValidator.ts @@ -6,20 +6,19 @@ import {ResourceParser} from './common/resourceParser.js'; import type {Suppression, Tool, ValidationResponse, ValidationResult, ValidationRun} from './common/sarif.js'; import type {CustomSchema, Plugin, Resource} from './common/types.js'; import {Config} from './config/parse.js'; -import {CIS_TAXONOMY, NSA_TAXONOMY} from './taxonomies'; +import {CIS_TAXONOMY, NSA_TAXONOMY} from './taxonomies/index.js'; import {PluginMetadataWithConfig, PluginName, RuleMetadataWithConfig, ValidateParams, Validator} from './types.js'; import {nextTick, throwIfAborted} from './utils/abort.js'; import {extractSchema, findDefaultVersion} from './utils/customResourceDefinitions.js'; import {PluginLoadError} from './utils/error.js'; import invariant from './utils/invariant.js'; import {isDefined} from './utils/isDefined.js'; -import {Fixer, Suppressor} from './sarif'; +import {Fixer, Suppressor} from './sarif/index.js'; import {SuppressEngine} from './sarif/suppressions/engine.js'; -import {SchemaLoader} from './validators'; +import {SchemaLoader} from './validators/index.js'; import {PluginLoader} from './pluginLoaders/PluginLoader.js'; import {ValidationConfig} from '@monokle/types'; -import {noop} from "lodash"; -import {PluginContext} from "./pluginLoaders/types"; +import {PluginContext} from './pluginLoaders/types.js'; export type ValidatorInit = { loader: PluginLoader; @@ -48,9 +47,9 @@ export class MonokleValidator implements Validator { parser: init.parser, fixer: init.fixer, schemaLoader: init.schemaLoader, - } + }; this._suppressor = new SuppressEngine(init.suppressors ?? []); - if (config) this.preload(config).catch(noop); + if (config) this.preload(config).catch(() => {}); } get config(): Config { @@ -106,9 +105,9 @@ export class MonokleValidator implements Validator { * @param config - the new configuration of the validator. * @param suppressions - a list with suppression requests. */ - async preload(config: Config, suppressions?: Suppression[]): Promise { - this._config = config; - this._suppressions = suppressions || []; + async preload(config?: Config, suppressions?: Suppression[]): Promise { + this._config = config ?? {}; + this._suppressions = suppressions ?? []; return this.load(); } diff --git a/packages/validation/src/__tests__/MonokleValidator.kubernetes-schema.test.ts b/packages/validation/src/__tests__/MonokleValidator.kubernetes-schema.test.ts index 9f199d2a7..ad3c62a07 100644 --- a/packages/validation/src/__tests__/MonokleValidator.kubernetes-schema.test.ts +++ b/packages/validation/src/__tests__/MonokleValidator.kubernetes-schema.test.ts @@ -1,6 +1,6 @@ import {expect, it} from 'vitest'; import {MonokleValidator} from '../MonokleValidator.js'; -import {processRefs} from '../references'; +import {processRefs} from '../references/index.js'; // Usage note: This library relies on fetch being on global scope! import 'isomorphic-fetch'; diff --git a/packages/validation/src/__tests__/MonokleValidator.metadata.test.ts b/packages/validation/src/__tests__/MonokleValidator.metadata.test.ts index 2885f3020..3c228f5a9 100644 --- a/packages/validation/src/__tests__/MonokleValidator.metadata.test.ts +++ b/packages/validation/src/__tests__/MonokleValidator.metadata.test.ts @@ -1,6 +1,6 @@ import {expect, it} from 'vitest'; import {MonokleValidator} from '../MonokleValidator.js'; -import {processRefs} from '../references'; +import {processRefs} from '../references/index.js'; // Usage note: This library relies on fetch being on global scope! import 'isomorphic-fetch'; diff --git a/packages/validation/src/__tests__/MonokleValidator.pss.test.ts b/packages/validation/src/__tests__/MonokleValidator.pss.test.ts index 24c59ec06..3ffad4b0f 100644 --- a/packages/validation/src/__tests__/MonokleValidator.pss.test.ts +++ b/packages/validation/src/__tests__/MonokleValidator.pss.test.ts @@ -1,6 +1,6 @@ import {expect, it} from 'vitest'; import {MonokleValidator} from '../MonokleValidator.js'; -import {processRefs} from '../references'; +import {processRefs} from '../references/index.js'; // Usage note: This library relies on fetch being on global scope! import 'isomorphic-fetch'; diff --git a/packages/validation/src/__tests__/MonokleValidator.test.ts b/packages/validation/src/__tests__/MonokleValidator.test.ts index 432dbcdb3..fcd274f4d 100644 --- a/packages/validation/src/__tests__/MonokleValidator.test.ts +++ b/packages/validation/src/__tests__/MonokleValidator.test.ts @@ -1,7 +1,7 @@ import Ajv from 'ajv'; import {expect, it} from 'vitest'; import {MonokleValidator} from '../MonokleValidator.js'; -import {processRefs} from '../references'; +import {processRefs} from '../references/index.js'; // Usage note: This library relies on fetch being on global scope! import 'isomorphic-fetch'; diff --git a/packages/validation/src/pluginLoaders/PluginLoader.ts b/packages/validation/src/pluginLoaders/PluginLoader.ts index 055d40692..6c834847b 100644 --- a/packages/validation/src/pluginLoaders/PluginLoader.ts +++ b/packages/validation/src/pluginLoaders/PluginLoader.ts @@ -14,7 +14,7 @@ import { YamlValidator } from '../validators'; import {PluginContext} from './types.js'; -import {RemoteWasmLoader} from "../validators/open-policy-agent/wasmLoader/RemoteWasmLoader.node"; +import {RemoteWasmLoader} from "../validators/open-policy-agent/wasmLoader/RemoteWasmLoader.browser"; export interface PluginLoader { load(plugin: string, ctx: PluginContext, settings?: Record): Plugin | Promise;