iac-test-result.d.ts 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import { BasicResultData, SEVERITY, TestDepGraphMeta } from './legacy';
  2. export interface AnnotatedIacIssue {
  3. id: string;
  4. publicId: string;
  5. title: string;
  6. description?: string;
  7. severity: SEVERITY | 'none';
  8. isIgnored: boolean;
  9. cloudConfigPath: string[];
  10. type?: string;
  11. subType: string;
  12. policyEngineType?: string;
  13. references: string[];
  14. path?: string[];
  15. documentation?: string;
  16. isGeneratedByCustomRule?: boolean;
  17. issue: string;
  18. impact: string;
  19. resolve: string;
  20. remediation?: Partial<Record<'terraform' | 'cloudformation' | 'arm' | 'kubernetes', string>>;
  21. msg: string;
  22. compliance?: string[][];
  23. name?: string;
  24. from?: string[];
  25. lineNumber?: number;
  26. iacDescription: {
  27. issue: string;
  28. impact: string;
  29. resolve: string;
  30. };
  31. }
  32. declare type FILTERED_OUT_FIELDS = 'cloudConfigPath' | 'name' | 'from';
  33. export interface IacTestResponse extends BasicResultData {
  34. path: string;
  35. targetFile: string;
  36. projectName: string;
  37. displayTargetFile: string;
  38. foundProjectCount: number;
  39. meta: TestDepGraphMeta;
  40. result: {
  41. cloudConfigResults: AnnotatedIacIssue[];
  42. projectType: string;
  43. };
  44. }
  45. declare const IAC_ISSUES_KEY = "infrastructureAsCodeIssues";
  46. export declare function mapIacTestResult(iacTest: IacTestResponse): MappedIacTestResponse | IacTestError;
  47. /**
  48. * The following types represent manipulations to the data structure returned from Registry's `test-iac`.
  49. * These manipulations are being done prior to outputing as JSON, for renaming fields only.
  50. * The types above, IacTestResult & AnnotatedIacIssue, represent how the response from Registry actually is.
  51. * These were introduced in order to prevent cascading complex changes caused by changing Registry's `test-iac` response.
  52. */
  53. export interface IacTestError {
  54. ok: boolean;
  55. error: string;
  56. path: string;
  57. }
  58. export interface MappedIacTestResponse extends Omit<IacTestResponse, 'result'> {
  59. [IAC_ISSUES_KEY]: MappedAnnotatedIacIssue[];
  60. projectType: string;
  61. }
  62. export interface MappedAnnotatedIacIssue extends Omit<AnnotatedIacIssue, FILTERED_OUT_FIELDS> {
  63. path: string[];
  64. }
  65. export declare function mapIacIssue(iacIssue: AnnotatedIacIssue): MappedAnnotatedIacIssue;
  66. export {};