policy-engine.d.ts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. /**
  2. * This is the top-level output from the Unified Policy Engine.
  3. * @export
  4. * @interface Results
  5. */
  6. export interface Results {
  7. /**
  8. *
  9. * @type {string}
  10. * @memberof Results
  11. */
  12. format: Results.FormatEnum;
  13. /**
  14. *
  15. * @type {string}
  16. * @memberof Results
  17. */
  18. formatVersion: Results.FormatVersionEnum;
  19. /**
  20. *
  21. * @type {Array<Result>}
  22. * @memberof Results
  23. */
  24. results: Array<Result>;
  25. }
  26. /**
  27. * @export
  28. * @namespace Results
  29. */
  30. declare namespace Results {
  31. /**
  32. * @export
  33. * @enum {string}
  34. */
  35. enum FormatEnum {
  36. Results = <any>'results'
  37. }
  38. /**
  39. * @export
  40. * @enum {string}
  41. */
  42. enum FormatVersionEnum {
  43. _100 = <any>'1.0.0'
  44. }
  45. }
  46. /**
  47. * An object that relates an input with its rule results
  48. * @export
  49. * @interface Result
  50. */
  51. interface Result {
  52. /**
  53. *
  54. * @type {State}
  55. * @memberof Result
  56. */
  57. input: State;
  58. /**
  59. * An array of rule results objects
  60. * @type {Array<RuleResults>}
  61. * @memberof Result
  62. */
  63. rule_results: Array<RuleResults>;
  64. }
  65. /**
  66. * The state format contains the state of all resources from some input. This format is intended to be used as both an input and output for the unified policy engine. It is also intended to support the visualizer and other downstream artifacts.
  67. * @export
  68. * @interface State
  69. */
  70. interface State {
  71. /**
  72. *
  73. * @type {string}
  74. * @memberof State
  75. */
  76. format: State.FormatEnum;
  77. /**
  78. *
  79. * @type {string}
  80. * @memberof State
  81. */
  82. formatVersion: State.FormatVersionEnum;
  83. /**
  84. * The type of input that this state was generated from. This value factors into which rules are run for this input.
  85. * @type {string}
  86. * @memberof State
  87. */
  88. input_type: State.InputTypeEnum;
  89. /**
  90. * The type of environment that this state was generated from. This value factors into which rules are run for this input.
  91. * @type {string}
  92. * @memberof State
  93. */
  94. environmentProvider: State.EnvironmentProviderEnum;
  95. /**
  96. * This object is intended to hold any input type-specific or environment-specific fields, e.g. account_id or filepath.
  97. * @type {{ [key: string]: ModelObject; }}
  98. * @memberof State
  99. */
  100. meta?: {
  101. [key: string]: any;
  102. };
  103. /**
  104. * Resources is a map of resource type to a map of a unique resource key to a resource object.
  105. * @type {{ [key: string]: { [key: string]: ResourceState; }; }}
  106. * @memberof State
  107. */
  108. resources: {
  109. [key: string]: {
  110. [key: string]: ResourceState;
  111. };
  112. };
  113. }
  114. /**
  115. * @export
  116. * @namespace State
  117. */
  118. export declare namespace State {
  119. /**
  120. * @export
  121. * @enum {string}
  122. */
  123. enum FormatEnum {
  124. State
  125. }
  126. /**
  127. * @export
  128. * @enum {string}
  129. */
  130. enum FormatVersionEnum {
  131. _100
  132. }
  133. /**
  134. * @export
  135. * @enum {string}
  136. */
  137. enum InputTypeEnum {
  138. TfHcl,
  139. TfPlan,
  140. CloudScan,
  141. Cfn,
  142. K8s,
  143. Arm
  144. }
  145. /**
  146. * @export
  147. * @enum {string}
  148. */
  149. enum EnvironmentProviderEnum {
  150. Aws,
  151. Azure,
  152. Google,
  153. Iac
  154. }
  155. }
  156. /**
  157. * The state of a single resource
  158. * @export
  159. * @interface ResourceState
  160. */
  161. interface ResourceState {
  162. /**
  163. * The identifier of the object. This can be a natural ID. It is assumed that this ID is unique within the namespace.
  164. * @type {string}
  165. * @memberof ResourceState
  166. */
  167. id: string;
  168. /**
  169. * The type of the resource.
  170. * @type {string}
  171. * @memberof ResourceState
  172. */
  173. resourceType: string;
  174. /**
  175. * This field is a component of uniquely identifying a resource. It will resolve to different values depending on the input type and environment provider. For example, in a runtime AWS environment, this will be the region. For an IaC Terraform resource, this will be the module path. Customers of the API can set this to something that makes sense for them and parse it back.
  176. * @type {string}
  177. * @memberof ResourceState
  178. */
  179. namespace: string;
  180. /**
  181. * Tags applied to the resource. Our goal is to extract tags into a uniform key->value format.
  182. * @type {{ [key: string]: string; }}
  183. * @memberof ResourceState
  184. */
  185. tags?: {
  186. [key: string]: string;
  187. };
  188. /**
  189. * This object is intended to hold any input type-specific or environment-specific fields, e.g. provider, region, or source location.
  190. * @type {{ [key: string]: ModelObject; }}
  191. * @memberof ResourceState
  192. */
  193. meta?: {
  194. [key: string]: any;
  195. };
  196. /**
  197. * A map of resource attributes.
  198. * @type {{ [key: string]: ModelObject; }}
  199. * @memberof ResourceState
  200. */
  201. attributes: {
  202. [key: string]: RuleResultResourceAttribute;
  203. };
  204. }
  205. /**
  206. * Container for all results associated with a single rule
  207. * @export
  208. * @interface RuleResults
  209. */
  210. export interface RuleResults {
  211. /**
  212. * The Rule ID, e.g. SNYK_00503 or 608f97c3-a11a-4154-a88e-a2fcd18c75b0
  213. * @type {string}
  214. * @memberof RuleResults
  215. */
  216. id?: string;
  217. /**
  218. * The rule title
  219. * @type {string}
  220. * @memberof RuleResults
  221. */
  222. title?: string;
  223. /**
  224. * The platform describes the CSPs or other technology platform (e.g. Docker) that the rule checks for
  225. * @type {Array<string>}
  226. * @memberof RuleResults
  227. */
  228. platform?: Array<string>;
  229. /**
  230. * The rule description
  231. * @type {string}
  232. * @memberof RuleResults
  233. */
  234. description?: string;
  235. /**
  236. * A markdown formatted string containing useful links
  237. * @type {string}
  238. * @memberof RuleResults
  239. */
  240. references?: string;
  241. /**
  242. * The category of the policy
  243. * @type {string}
  244. * @memberof RuleResults
  245. */
  246. category?: string;
  247. /**
  248. * An array of labels (value-less tags) associated with this policy
  249. * @type {Array<string>}
  250. * @memberof RuleResults
  251. */
  252. labels?: Array<string>;
  253. /**
  254. * The service group of the primary resource associated with this policy (e.g. \"EBS\", \"EC2\")
  255. * @type {string}
  256. * @memberof RuleResults
  257. */
  258. serviceGroup?: string;
  259. /**
  260. * A map of rule set ID to a map of versions to a list of control IDs
  261. * @type {{ [key: string]: { [key: string]: Array<string>; }; }}
  262. * @memberof RuleResults
  263. */
  264. controls?: {
  265. [key: string]: {
  266. [key: string]: Array<string>;
  267. };
  268. };
  269. /**
  270. * A list of resource types that the rule uses.
  271. * @type {Array<string>}
  272. * @memberof RuleResults
  273. */
  274. resourceTypes?: Array<string>;
  275. /**
  276. *
  277. * @type {Array<RuleResult>}
  278. * @memberof RuleResults
  279. */
  280. results: Array<RuleResult>;
  281. /**
  282. * Any errors that occurred while evaluating this rule.
  283. * @type {Array<string>}
  284. * @memberof RuleResults
  285. */
  286. errors?: Array<string>;
  287. /**
  288. * The Rego package name that defines the rule, useful for debugging
  289. * @type {string}
  290. * @memberof RuleResults
  291. */
  292. _package?: string;
  293. }
  294. /**
  295. * A single rule result
  296. * @export
  297. * @interface RuleResult
  298. */
  299. export interface RuleResult {
  300. /**
  301. * Whether or not this is a passing or failing result
  302. * @type {boolean}
  303. * @memberof RuleResult
  304. */
  305. passed: boolean;
  306. /**
  307. * Whether or not this result is ignored
  308. * @type {boolean}
  309. * @memberof RuleResult
  310. */
  311. ignored: boolean;
  312. /**
  313. * An optional message that can be returned by a rule
  314. * @type {string}
  315. * @memberof RuleResult
  316. */
  317. message?: string;
  318. /**
  319. * The ID of the primary resource (if any) associated with this result
  320. * @type {string}
  321. * @memberof RuleResult
  322. */
  323. resourceId?: string;
  324. /**
  325. * The namespace of the primary resource (if any) associated with this result
  326. * @type {string}
  327. * @memberof RuleResult
  328. */
  329. resourceNamespace?: string;
  330. /**
  331. * The type of resource (if any) associated with this result. This will typically be used with \"missing resource\" rules.
  332. * @type {string}
  333. * @memberof RuleResult
  334. */
  335. resourceType?: string;
  336. /**
  337. * A Markdown-formatted set of remediation steps to resolve the issue identified by the rule
  338. * @type {string}
  339. * @memberof RuleResult
  340. */
  341. remediation?: string;
  342. /**
  343. * The severity of this rule result
  344. * @type {string}
  345. * @memberof RuleResult
  346. */
  347. severity?: RuleResult.SeverityEnum;
  348. /**
  349. * An arbitrary key-value map that a rule can return in its result.
  350. * @type {{ [key: string]: ModelObject; }}
  351. * @memberof RuleResult
  352. */
  353. context?: {
  354. [key: string]: any;
  355. };
  356. /**
  357. * A resource objects associated with this result.
  358. * @type {Array<RuleResultResource>}
  359. * @memberof RuleResult
  360. */
  361. resources?: Array<RuleResultResource>;
  362. }
  363. /**
  364. * @export
  365. * @namespace RuleResult
  366. */
  367. declare namespace RuleResult {
  368. /**
  369. * @export
  370. * @enum {string}
  371. */
  372. enum SeverityEnum {
  373. Low = <any>'Low',
  374. Medium = <any>'Medium',
  375. High = <any>'High',
  376. Critical = <any>'Critical'
  377. }
  378. }
  379. /**
  380. * Identifying information for a resource and attributes associated with a rule result
  381. * @export
  382. * @interface RuleResultResource
  383. */
  384. interface RuleResultResource {
  385. /**
  386. * The ID of this resource
  387. * @type {string}
  388. * @memberof RuleResultResource
  389. */
  390. id?: string;
  391. /**
  392. * The type of this resource
  393. * @type {string}
  394. * @memberof RuleResultResource
  395. */
  396. type?: string;
  397. /**
  398. * The namespace of this resource
  399. * @type {string}
  400. * @memberof RuleResultResource
  401. */
  402. namespace?: string;
  403. /**
  404. *
  405. * @type {SourceLocationStack}
  406. * @memberof RuleResultResource
  407. */
  408. location?: SourceLocationStack;
  409. /**
  410. * Attributes of the resource that were associated with a rule result.
  411. * @type {Array<RuleResultResourceAttribute>}
  412. * @memberof RuleResultResource
  413. */
  414. attributes?: Array<RuleResultResourceAttribute>;
  415. }
  416. /**
  417. * Points to a row and column within a source file
  418. * @export
  419. * @interface SourceLocation
  420. */
  421. interface SourceLocation {
  422. /**
  423. *
  424. * @type {string}
  425. * @memberof SourceLocation
  426. */
  427. filepath?: string;
  428. /**
  429. *
  430. * @type {number}
  431. * @memberof SourceLocation
  432. */
  433. line?: number;
  434. /**
  435. *
  436. * @type {number}
  437. * @memberof SourceLocation
  438. */
  439. column?: number;
  440. }
  441. /**
  442. * A stack of source locations. It's useful to represent locations this way for IaC types that allow users to import modules or other groups of resources, because we can point to where a resource definition is as well as how it was imported into the top-level module.
  443. * @export
  444. */
  445. declare type SourceLocationStack = Array<SourceLocation>;
  446. /**
  447. *
  448. * @export
  449. * @interface RuleResultResourceAttribute
  450. */
  451. interface RuleResultResourceAttribute {
  452. /**
  453. * The path to an attribute associated with this resource and rule result
  454. * @type {Array<string | number>}
  455. * @memberof RuleResultResourceAttribute
  456. */
  457. path?: Array<string | number>;
  458. /**
  459. *
  460. * @type {SourceLocation}
  461. * @memberof RuleResultResourceAttribute
  462. */
  463. location?: SourceLocation;
  464. }
  465. export {};