legacy.d.ts 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. import * as depGraphLib from '@snyk/dep-graph';
  2. import { DepsFilePaths, ScanResult, FileSignaturesDetails } from '../ecosystems/types';
  3. import { SupportedPackageManagers } from '../package-managers';
  4. import { Options, SupportedProjectTypes, TestOptions } from '../types';
  5. interface Pkg {
  6. name: string;
  7. version?: string;
  8. }
  9. interface Patch {
  10. version: string;
  11. id: string;
  12. urls: string[];
  13. modificationTime: string;
  14. }
  15. export declare enum SEVERITY {
  16. LOW = "low",
  17. MEDIUM = "medium",
  18. HIGH = "high",
  19. CRITICAL = "critical"
  20. }
  21. export interface VulnMetaData {
  22. id: string;
  23. title: string;
  24. description: string;
  25. type: 'license' | 'vuln';
  26. name: string;
  27. info: string;
  28. severity: SEVERITY;
  29. severityValue: number;
  30. isNew: boolean;
  31. version: string;
  32. packageManager: SupportedPackageManagers | 'upstream';
  33. }
  34. export interface GroupedVuln {
  35. list: AnnotatedIssue[];
  36. metadata: VulnMetaData;
  37. isIgnored: boolean;
  38. title: string;
  39. note: string | false;
  40. severity: SEVERITY;
  41. originalSeverity?: SEVERITY;
  42. isNew: boolean;
  43. name: string;
  44. version: string;
  45. isFixable: boolean;
  46. fixedIn: string[];
  47. legalInstructionsArray?: LegalInstruction[];
  48. }
  49. export interface LegalInstruction {
  50. licenseName: string;
  51. legalContent: string;
  52. }
  53. export interface IssueData {
  54. id: string;
  55. packageName: string;
  56. version: string;
  57. moduleName?: string;
  58. below: string;
  59. semver: {
  60. vulnerable: string | string[];
  61. vulnerableHashes?: string[];
  62. vulnerableByDistro?: {
  63. [distroNameAndVersion: string]: string[];
  64. };
  65. };
  66. patches: Patch[];
  67. isNew: boolean;
  68. description: string;
  69. title: string;
  70. severity: SEVERITY;
  71. fixedIn: string[];
  72. legalInstructions?: string;
  73. packageManager?: SupportedProjectTypes;
  74. from?: string[];
  75. name?: string;
  76. }
  77. export declare type CallPath = string[];
  78. interface AnnotatedIssue extends IssueData {
  79. credit: string[];
  80. name: string;
  81. version: string;
  82. from: string[];
  83. upgradePath: Array<string | boolean>;
  84. isUpgradable: boolean;
  85. isPatchable: boolean;
  86. severity: SEVERITY;
  87. originalSeverity?: SEVERITY;
  88. bundled?: any;
  89. shrinkwrap?: any;
  90. __filename?: string;
  91. parentDepType: string;
  92. type?: 'license';
  93. title: string;
  94. patch?: any;
  95. note?: string | false;
  96. publicationTime?: string;
  97. identifiers?: {
  98. [name: string]: string[];
  99. };
  100. }
  101. export interface DockerIssue {
  102. nearestFixedInVersion?: string;
  103. dockerfileInstruction?: any;
  104. dockerBaseImage?: any;
  105. }
  106. export interface IgnoreSettings {
  107. adminOnly: boolean;
  108. reasonRequired: boolean;
  109. disregardFilesystemIgnores: boolean;
  110. }
  111. export interface BasicResultData {
  112. ok: boolean;
  113. payloadType?: string;
  114. org: string;
  115. isPrivate: boolean;
  116. summary: string;
  117. packageManager?: SupportedProjectTypes;
  118. severityThreshold?: string;
  119. platform?: string;
  120. }
  121. export interface LegacyVulnApiResult extends BasicResultData {
  122. vulnerabilities: AnnotatedIssue[];
  123. dependencyCount: number;
  124. policy: string;
  125. licensesPolicy: object | null;
  126. ignoreSettings: IgnoreSettings | null;
  127. docker?: {
  128. baseImage?: any;
  129. binariesVulns?: unknown;
  130. baseImageRemediation?: BaseImageRemediation;
  131. };
  132. projectId?: string;
  133. filesystemPolicy?: boolean;
  134. uniqueCount?: any;
  135. remediation?: RemediationChanges;
  136. }
  137. export interface BaseImageRemediation {
  138. code: string;
  139. advice: BaseImageRemediationAdvice[];
  140. message?: string;
  141. }
  142. export interface BaseImageRemediationAdvice {
  143. message: string;
  144. bold?: boolean;
  145. color?: string;
  146. }
  147. export interface TestResult extends LegacyVulnApiResult {
  148. targetFile?: string;
  149. projectName?: string;
  150. targetFilePath?: string;
  151. displayTargetFile?: string;
  152. foundProjectCount?: number;
  153. scanResult?: ScanResult;
  154. }
  155. interface UpgradePathItem {
  156. name: string;
  157. version: string;
  158. newVersion?: string;
  159. isDropped?: boolean;
  160. }
  161. interface UpgradePath {
  162. path: UpgradePathItem[];
  163. }
  164. interface FixInfo {
  165. upgradePaths: UpgradePath[];
  166. isPatchable: boolean;
  167. nearestFixedInVersion?: string;
  168. }
  169. export interface AffectedPackages {
  170. [pkgId: string]: {
  171. pkg: Pkg;
  172. issues: {
  173. [issueId: string]: Issue;
  174. };
  175. };
  176. }
  177. interface TestDepGraphResult {
  178. issuesData: {
  179. [issueId: string]: IssueData;
  180. };
  181. affectedPkgs: AffectedPackages;
  182. docker: {
  183. binariesVulns?: TestDepGraphResult;
  184. baseImage?: any;
  185. };
  186. remediation?: RemediationChanges;
  187. }
  188. export interface Issue {
  189. pkgName: string;
  190. pkgVersion?: string;
  191. issueId: string;
  192. fixInfo: FixInfo;
  193. }
  194. export interface TestDependenciesResult {
  195. issuesData: {
  196. [issueId: string]: IssueData;
  197. };
  198. issues: Issue[];
  199. docker?: {
  200. baseImage: string;
  201. baseImageRemediation: BaseImageRemediation;
  202. binariesVulns: TestDepGraphResult;
  203. };
  204. remediation?: RemediationChanges;
  205. depsFilePaths?: DepsFilePaths;
  206. depGraphData: depGraphLib.DepGraphData;
  207. fileSignaturesDetails: FileSignaturesDetails;
  208. vulnerabilities: IssueData[];
  209. path: string;
  210. dependencyCount: number;
  211. packageManager: SupportedProjectTypes;
  212. }
  213. export interface TestDepGraphMeta {
  214. isPublic: boolean;
  215. isLicensesEnabled: boolean;
  216. licensesPolicy?: {
  217. severities: {
  218. [type: string]: string;
  219. };
  220. };
  221. projectId?: string;
  222. ignoreSettings?: IgnoreSettings;
  223. policy: string;
  224. org: string;
  225. }
  226. export interface TestDepGraphResponse {
  227. result: TestDepGraphResult;
  228. meta: TestDepGraphMeta;
  229. }
  230. export interface TestDependenciesResponse {
  231. result: TestDependenciesResult;
  232. meta: TestDepGraphMeta;
  233. }
  234. export interface Ignores {
  235. [path: string]: {
  236. paths: string[][];
  237. meta: {
  238. days?: number;
  239. reason?: string;
  240. };
  241. };
  242. }
  243. export interface PatchObject {
  244. [name: string]: {
  245. patched: string;
  246. };
  247. }
  248. export interface Upgrade {
  249. upgradeTo: string;
  250. }
  251. export interface UpgradeVulns extends Upgrade {
  252. vulns: string[];
  253. }
  254. export interface UpgradeRemediation extends UpgradeVulns {
  255. upgrades: string[];
  256. }
  257. export interface PatchRemediation {
  258. paths: PatchObject[];
  259. }
  260. export interface DependencyUpdates {
  261. [from: string]: UpgradeRemediation;
  262. }
  263. export interface PinRemediation extends UpgradeVulns {
  264. isTransitive: boolean;
  265. }
  266. export interface DependencyPins {
  267. [name: string]: PinRemediation;
  268. }
  269. export interface RemediationChanges {
  270. unresolved: IssueData[];
  271. upgrade: DependencyUpdates;
  272. patch: {
  273. [name: string]: PatchRemediation;
  274. };
  275. ignore: unknown;
  276. pin: DependencyPins;
  277. }
  278. declare function convertTestDepGraphResultToLegacy(res: TestDepGraphResponse, depGraph: depGraphLib.DepGraph, packageManager: SupportedProjectTypes | undefined, options: Options & TestOptions): LegacyVulnApiResult;
  279. export { convertTestDepGraphResultToLegacy, AnnotatedIssue };