import { Scalar } from 'yaml'; import { RuleMap } from '../config/parse.js'; import { PluginMetadataWithConfig, RuleMetadataWithConfig } from '../types.js'; import { ResourceSchema } from '../validators/kubernetes-schema/schemaLoader.js'; import { ResourceParser } from './resourceParser.js'; import { ToolPlugin, ValidationPolicy, ValidationResult } from './sarif.js'; export declare type YamlPath = Array; export declare type Resource = { id: string; fileId: string; filePath: string; fileOffset: number; name: string; apiVersion: string; kind: string; namespace?: string; content?: any; text: string; isSelected?: boolean; refs?: ResourceRef[]; range?: { start: number; length: number; }; }; export declare type ResourceRefsProcessingConfig = { /** * Whether optional, unsatisfied references should be ignored. **/ shouldIgnoreOptionalUnsatisfiedRefs: boolean; /** * A shared resource parser. */ parser: ResourceParser; }; export declare type RefNode = { scalar: Scalar; key: string; parentKeyPath: string; }; export declare type ResourceMapType = { [id: string]: Resource | undefined; }; export declare enum ResourceRefType { Incoming = "incoming", Outgoing = "outgoing", Unsatisfied = "unsatisfied-outgoing", IncomingOwner = "incoming-owner", OutgoingOwner = "outgoing-owner", UnsatisfiedOwner = "unsatisfied-outgoing-owner" } export declare type RefTargetResource = { type: 'resource'; resourceId?: string; resourceKind?: string; isOptional?: boolean; }; export declare type RefTargetFile = { type: 'file'; filePath: string; }; export declare type RefTargetImage = { type: 'image'; tag: string; }; export declare type RefTarget = RefTargetResource | RefTargetFile | RefTargetImage; export interface ResourceRef { /** the type of ref (see enum) */ type: ResourceRefType; /** the ref value - for example the name of a configmap */ name: string; /** the target resource or file this is referring to (empty for unsatisfied refs) */ target?: TRefTarget; /** the position in the document of the refName (undefined for incoming file refs) */ position?: RefPosition; } export interface RefPosition { line: number; column: number; length: number; endLine?: number; endColumn?: number; } export declare type CustomSchema = { kind: string; apiVersion: string; schema: ResourceSchema; }; export declare type ToolConfig = { tool: T; enabled: boolean; policy?: ValidationPolicy; }; export declare type Incremental = { resourceIds: string[]; }; export interface PluginConstructor { new (parser: ResourceParser): Plugin; } export declare type PluginMetadata = { /** * The identifier of this plugin. * * @remark This is the prefix of all rule identifiers. * @example "KSV" */ id: string; /** * The name of this plugin * * @example "open-policy-agent" */ name: string; /** * The display name of this plugin * * @example "Open Policy Agent */ displayName: string; /** * The description of this plugin. */ description: string; /** * The icon of this plugin */ icon?: string; /** * The website of this plugin. */ learnMoreUrl?: string; /** * Whether the plugin is in development. */ dev?: boolean; }; export declare type PluginConfig = { /** * Whether the plugin is enabled. */ enabled?: boolean; }; export declare type ValidateOptions = { incremental?: Incremental; }; export interface Plugin { /** * The name of this plugin. * * @deprecated use metadata.name. */ get name(): string; /** * The metadata of the plugin. */ get metadata(): PluginMetadataWithConfig; /** * The SARIF tool component. */ get toolComponent(): ToolPlugin; /** * The SARIF tool component index. */ get toolComponentIndex(): number; set toolComponentIndex(value: number); /** * The rules of this plugin. */ get rules(): RuleMetadataWithConfig[]; get enabled(): boolean; set enabled(value: boolean); /** * Whether the rule exists in this plugin. * * @rule Either the rule identifier or display name. * @example "KSV013" or "open-policy-agent/no-latest-image" */ hasRule(rule: string): boolean; /** * Whether the rule is enabled in this plugin. * * @rule Either the rule identifier or display name. * @example "KSV013" or "open-policy-agent/no-latest-image" */ isRuleEnabled(rule: string): boolean; /** * Configures the validator. * * @remark Configure should be idempotent. A validator can be invoked * multiple times with unchanged settings because another validator changed. */ configure(config: { rules?: RuleMap; settings?: any; }): Promise; registerCustomSchema(schema: CustomSchema, crd?: Resource): Promise | void; unregisterCustomSchema(schema: Omit): Promise | void; validate(resources: Resource[], options: ValidateOptions): Promise; clear(): Promise; unload(): Promise; }