@@ -1120,13 +1120,12 @@ type killing_parent = {
1120
1120
* types used to communicate with the Semgrep backend and are not meant
1121
1121
* to be consumed directly by Semgrep users or tools wrapping Semgrep.
1122
1122
*
1123
- * The sequence of HTTP requests is mostly:
1124
- * - /deployments/current with token
1123
+ * The sequence of HTTP requests for 'semgrep ci' is mostly:
1124
+ * - /api/agent/ deployments/current with token
1125
1125
* and response with deployment name in a deployment config
1126
- * - /deployments/scans when starting a scan, with information about the project
1127
- * and response with scan_id
1128
- * - /scans/<scan_id>/config to request the scan config
1129
- * and response with scan_config including the rules to use
1126
+ * (TODO? get rid of this one? useful?)
1127
+ * - /api/cli/scans when starting a scan, with information about the project
1128
+ * and response with scan_id and scan_config including the rules to use
1130
1129
* - /results to send the findings to the backend
1131
1130
* and response with errors and task_id
1132
1131
* - /complete when done, with the exit code and a few more information
@@ -1186,7 +1185,7 @@ type action = [
1186
1185
]
1187
1186
1188
1187
(* ----------------------------- *)
1189
- (* CI Configuration *)
1188
+ (* CI configurations *)
1190
1189
(* ----------------------------- *)
1191
1190
1192
1191
(* Response by the backend to the CLI to the POST deployments/current *)
@@ -1222,21 +1221,16 @@ type ci_config_from_repo = {
1222
1221
(* ex: "webapp" *)
1223
1222
type tag = string
1224
1223
1225
- (* Response by the backend to the CLI to the POST /scans/<scan_id>/config *)
1224
+ (* Response by the backend to the CLI to the POST deployments/scans/config
1225
+ * DEPRECATED? seems to be used only by semgrep lsp.
1226
+ *)
1226
1227
type scan_config = {
1227
- (* TODO: remove deployment_id + deployment_name from here, instead this
1228
- * will be in scan_response.scan_info
1229
- *)
1230
1228
deployment_id: int;
1231
1229
deployment_name: string;
1232
1230
(* ex: "audit", "comment", "block" TODO use enum? TODO: seems dead *)
1233
1231
policy_names: string list;
1234
1232
(* rules raw content in JSON format (but still sent as a string) *)
1235
1233
rule_config: string;
1236
- (* since 1.47.0 but not created by the backend (nor used by the CLI) *)
1237
- ?ci_config_from_cloud: ci_config_from_cloud option;
1238
-
1239
- (* Deprecated: should rely on ci_config_from_cloud instead *)
1240
1234
inherit features;
1241
1235
inherit triage_ignored;
1242
1236
(* glob patterns *)
@@ -1245,8 +1239,70 @@ type scan_config = {
1245
1239
?enabled_products: product list option;
1246
1240
(* since 1.64.0 *)
1247
1241
~actions: action list;
1242
+ (* since 1.47.0 but not created by the backend (nor used by the CLI) *)
1243
+ ?ci_config_from_cloud: ci_config_from_cloud option;
1248
1244
}
1249
1245
1246
+ (* Response from the backend to the CLI to the POST /api/cli/scans *)
1247
+ type scan_response = {
1248
+ info: scan_info;
1249
+ config: scan_configuration;
1250
+ engine_params: engine_configuration;
1251
+ (* TODO: ~actions: action list; *)
1252
+ }
1253
+
1254
+ (* meta info about the scan *)
1255
+ type scan_info = {
1256
+ ?id: int option; (* the scan id, null for dry-runs *)
1257
+ enabled_products: product list;
1258
+ (* redundant with deployment_config?
1259
+ * TODO? remove the intermediate call to get the deployment and
1260
+ * start a scan to /api/cli/scans/ without first accessing
1261
+ * api/agent/deployments/current?
1262
+ *)
1263
+ deployment_id: int;
1264
+ deployment_name: string;
1265
+ }
1266
+
1267
+ (* config specific to the scan, eg *)
1268
+ type scan_configuration = {
1269
+ rules: raw_json; (* can we type this better *)
1270
+ inherit triage_ignored;
1271
+ }
1272
+
1273
+ (* settings for the cli *)
1274
+ type engine_configuration = {
1275
+ inherit features;
1276
+ (* TODO? glob list? fpath list? *)
1277
+ ~ignored_files: string list;
1278
+ (* from 1.71.0 *)
1279
+ ?product_ignored_files: product_ignored_files option;
1280
+ (* for features we only want to turn on for select customers *)
1281
+ ~generic_slow_rollout: bool;
1282
+ (* from 1.63.0 *)
1283
+ ?historical_config: historical_configuration option;
1284
+ (* from 1.93.
1285
+ * Indicate that fail-open should always be enabled, overriding the CLI flag.
1286
+ * coupling: server/semgrep_app/saas/models/deployment_products_mixin.py
1287
+ *)
1288
+ ~always_suppress_errors: bool;
1289
+ }
1290
+
1291
+ type glob = string
1292
+
1293
+ type product_ignored_files = (product * glob list) list
1294
+ (* We omit the usual <json repr="object"> otherwise we get a
1295
+ * "keys must be strings" error *)
1296
+ <python repr="dict"> <ts repr="map">
1297
+
1298
+ (* configuration for scanning version control history,
1299
+ * e.g., looking back at past git commits for committed credentials which may
1300
+ * have been removed *)
1301
+ type historical_configuration = {
1302
+ enabled: bool;
1303
+ ?lookback_days: int option;
1304
+ }
1305
+
1250
1306
(* ----------------------------- *)
1251
1307
(* CI Deployment response *)
1252
1308
(* ----------------------------- *)
@@ -1258,13 +1314,27 @@ type deployment_response = {
1258
1314
(* CI Scan request *)
1259
1315
(* ----------------------------- *)
1260
1316
1317
+ (* Sent by the CLI to the POST /api/cli/scans to create a scan. *)
1318
+ type scan_request = {
1319
+ (* added in 1.43 as options, and mandatory since 1.100.0 (replacing meta) *)
1320
+ project_metadata: project_metadata;
1321
+ scan_metadata: scan_metadata;
1322
+
1323
+ (* added in 1.43 *)
1324
+ ?project_config: ci_config_from_repo option;
1325
+
1326
+ (* deprecated: moved as an option in 1.100.0 and was duplicative of
1327
+ * information in project_metadata and scan_metadata since 1.43.0
1328
+ * old: 'meta: project_metadata;' before 1.43
1329
+ *)
1330
+ ?meta: raw_json option;
1331
+ }
1332
+
1261
1333
(* Collect information about a project from the environment, filesystem,
1262
1334
* git repo, etc.
1263
1335
* See also semgrep_metrics.atd and PRIVACY.md
1264
- *
1265
- * TODO:
1266
- * - we could split it in different parts and use inherit to make things clearer
1267
- * (while still being backward compatible)
1336
+ * TODO: we could split it in different parts and use inherit to make things
1337
+ * clearer (while still being backward compatible)
1268
1338
*)
1269
1339
type project_metadata = {
1270
1340
(* TODO: deprecate in favor of scan_metadata.cli_version *)
@@ -1353,77 +1423,6 @@ type scan_metadata = {
1353
1423
?sms_scan_id: string option;
1354
1424
}
1355
1425
1356
- (* Sent by the CLI to the POST /api/cli/scans to create a scan. *)
1357
- type scan_request = {
1358
- (* added in 1.43 as options, and mandatory since 1.100.0 (replacing meta) *)
1359
- project_metadata: project_metadata;
1360
- scan_metadata: scan_metadata;
1361
-
1362
- (* added in 1.43 *)
1363
- ?project_config: ci_config_from_repo option;
1364
-
1365
- (* deprecated: moved as an option in 1.100.0 and was duplicative of
1366
- * information in project_metadata and scan_metadata since 1.43.0
1367
- * old: 'meta: project_metadata;' before 1.43
1368
- *)
1369
- ?meta: raw_json option;
1370
- }
1371
-
1372
- (* Response from the backend to the CLI to the POST /api/cli/scans *)
1373
- type scan_response = {
1374
- info: scan_info;
1375
- config: scan_configuration;
1376
- engine_params: engine_configuration;
1377
- }
1378
-
1379
- (* meta info about the scan *)
1380
- type scan_info = {
1381
- ?id: int option; (* the scan id, null for dry-runs *)
1382
- enabled_products: product list;
1383
- deployment_id: int;
1384
- deployment_name: string;
1385
- }
1386
-
1387
-
1388
-
1389
- (* config specific to the scan, eg *)
1390
- type scan_configuration = {
1391
- rules: raw_json; (* can we type this better *)
1392
- inherit triage_ignored;
1393
- }
1394
-
1395
- (* configuration for scanning version control history,
1396
- * e.g., looking back at past git commits for committed credentials which may
1397
- * have been removed *)
1398
- type historical_configuration = {
1399
- enabled: bool;
1400
- ?lookback_days: int option;
1401
- }
1402
-
1403
- type glob = string
1404
-
1405
- type product_ignored_files = (product * glob list) list
1406
- (* We omit the usual <json repr="object"> otherwise we get a
1407
- * "keys must be strings" error *)
1408
- <python repr="dict"> <ts repr="map">
1409
-
1410
- (* settings for the cli *)
1411
- type engine_configuration = {
1412
- inherit features;
1413
- ~ignored_files: string list;
1414
- (* from 1.71.0 *)
1415
- ?product_ignored_files: product_ignored_files option;
1416
- (* for features we only want to turn on for select customers *)
1417
- ~generic_slow_rollout: bool;
1418
- (* from 1.63.0 *)
1419
- ?historical_config: historical_configuration option;
1420
- (* from 1.93.
1421
- * Indicate that fail-open should always be enabled, overriding the CLI flag.
1422
- * coupling: server/semgrep_app/saas/models/deployment_products_mixin.py
1423
- *)
1424
- ~always_suppress_errors: bool;
1425
- }
1426
-
1427
1426
(* ----------------------------- *)
1428
1427
(* Findings *)
1429
1428
(* ----------------------------- *)
0 commit comments