Skip to content

Commit 533177d

Browse files
authored
Regenerate semgrep_output_v1.py with atdpy 3.0.1 (#426)
atdpy now honors `<doc text="...">` annotations like atdgen and turns them into Python docstrings. - [x] I ran `make setup && make` to update the generated code after editing a `.atd` file (TODO: have a CI check) - [x] I made sure we're still backward compatible with old versions of the CLI. For example, the Semgrep backend need to still be able to *consume* data generated by Semgrep 1.50.0. See https://atd.readthedocs.io/en/latest/atdgen-tutorial.html#smooth-protocol-upgrades Note that the types related to the semgrep-core JSON output or the semgrep-core RPC do not need to be backward compatible! - [x] Any accompanying changes in `semgrep-proprietary` are approved and ready to merge once this PR is merged
1 parent 28a800e commit 533177d

11 files changed

+2555
-3899
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@
66
*.cmi
77
*.cmo
88
Language
9+
10+
# Generated by ./scripts/check-backwards-compatibility
11+
before.txt
12+
after.txt

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ force-build:
3838
.PHONY: build
3939
build: $(FILES)
4040

41-
# need atdpy >= 2.11.0 to support parametrized types
41+
# need atdpy >= 3.0.0 to translate <doc text=...> into Python docstrings
4242
# need atdpy >= 2.12.0 for semgrep_metric.py
43+
# need atdpy >= 2.11.0 to support parametrized types
4344
%.py: %.atd
4445
atdpy $<
4546

semgrep-interfaces.opam

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ license: "LGPL-2.1-only"
1111

1212
build: []
1313
install: []
14-
14+
1515
depends: [
1616
"atd" {>= "2.6.0"}
17-
"atdpy" {>= "2.12.0"}
17+
"atdpy" {>= "3.0.0"}
1818
"atdts" {>= "2.13.0"}
19-
"atdgen" {>= "2.10.0"}
19+
"atdgen" {>= "3.0.1"}
2020
]
2121

2222
#TODO: we don't build on ubuntu or debian ever, and they are not packages there,

semgrep_metrics.py

Lines changed: 58 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ def write_option(x: Any) -> Any:
265265

266266
@dataclass
267267
class SupplyChainConfig:
268-
"""Original type: supply_chain_config = { ... }"""
268+
"""Original type: supply_chain_config = { ... }
269+
"""
269270

270271
_rfu: Optional[int] = None
271272

@@ -294,7 +295,8 @@ def to_json_string(self, **kw: Any) -> str:
294295

295296
@dataclass
296297
class Any_:
297-
"""Original type: secrets_origin = [ ... | Any | ... ]"""
298+
"""Original type: secrets_origin = [ ... | Any | ... ]
299+
"""
298300

299301
@property
300302
def kind(self) -> str:
@@ -311,7 +313,8 @@ def to_json_string(self, **kw: Any) -> str:
311313

312314
@dataclass
313315
class Semgrep:
314-
"""Original type: secrets_origin = [ ... | Semgrep | ... ]"""
316+
"""Original type: secrets_origin = [ ... | Semgrep | ... ]
317+
"""
315318

316319
@property
317320
def kind(self) -> str:
@@ -328,7 +331,8 @@ def to_json_string(self, **kw: Any) -> str:
328331

329332
@dataclass
330333
class NoCommunity:
331-
"""Original type: secrets_origin = [ ... | NoCommunity | ... ]"""
334+
"""Original type: secrets_origin = [ ... | NoCommunity | ... ]
335+
"""
332336

333337
@property
334338
def kind(self) -> str:
@@ -345,7 +349,8 @@ def to_json_string(self, **kw: Any) -> str:
345349

346350
@dataclass
347351
class SecretsOrigin:
348-
"""Original type: secrets_origin = [ ... ]"""
352+
"""Original type: secrets_origin = [ ... ]
353+
"""
349354

350355
value: Union[Any_, Semgrep, NoCommunity]
351356

@@ -379,7 +384,8 @@ def to_json_string(self, **kw: Any) -> str:
379384

380385
@dataclass
381386
class SecretsConfig:
382-
"""Original type: secrets_config = { ... }"""
387+
"""Original type: secrets_config = { ... }
388+
"""
383389

384390
permitted_origins: SecretsOrigin
385391

@@ -407,7 +413,8 @@ def to_json_string(self, **kw: Any) -> str:
407413

408414
@dataclass
409415
class ProFeatures:
410-
"""Original type: pro_features = { ... }"""
416+
"""Original type: pro_features = { ... }
417+
"""
411418

412419
diffDepth: Optional[int] = None
413420
numInterfileDiffScanned: Optional[List[Tuple[str, int]]] = None
@@ -440,7 +447,8 @@ def to_json_string(self, **kw: Any) -> str:
440447

441448
@dataclass
442449
class CodeConfig:
443-
"""Original type: code_config = { ... }"""
450+
"""Original type: code_config = { ... }
451+
"""
444452

445453
_rfu: Optional[int] = None
446454

@@ -469,7 +477,8 @@ def to_json_string(self, **kw: Any) -> str:
469477

470478
@dataclass
471479
class Intraprocedural:
472-
"""Original type: analysis_type = [ ... | Intraprocedural | ... ]"""
480+
"""Original type: analysis_type = [ ... | Intraprocedural | ... ]
481+
"""
473482

474483
@property
475484
def kind(self) -> str:
@@ -486,7 +495,8 @@ def to_json_string(self, **kw: Any) -> str:
486495

487496
@dataclass
488497
class Interprocedural:
489-
"""Original type: analysis_type = [ ... | Interprocedural | ... ]"""
498+
"""Original type: analysis_type = [ ... | Interprocedural | ... ]
499+
"""
490500

491501
@property
492502
def kind(self) -> str:
@@ -503,7 +513,8 @@ def to_json_string(self, **kw: Any) -> str:
503513

504514
@dataclass
505515
class Interfile:
506-
"""Original type: analysis_type = [ ... | Interfile | ... ]"""
516+
"""Original type: analysis_type = [ ... | Interfile | ... ]
517+
"""
507518

508519
@property
509520
def kind(self) -> str:
@@ -520,7 +531,8 @@ def to_json_string(self, **kw: Any) -> str:
520531

521532
@dataclass
522533
class AnalysisType:
523-
"""Original type: analysis_type = [ ... ]"""
534+
"""Original type: analysis_type = [ ... ]
535+
"""
524536

525537
value: Union[Intraprocedural, Interprocedural, Interfile]
526538

@@ -554,7 +566,8 @@ def to_json_string(self, **kw: Any) -> str:
554566

555567
@dataclass
556568
class EngineConfig:
557-
"""Original type: engine_config = { ... }"""
569+
"""Original type: engine_config = { ... }
570+
"""
558571

559572
analysis_type: AnalysisType
560573
pro_langs: bool
@@ -597,7 +610,8 @@ def to_json_string(self, **kw: Any) -> str:
597610

598611
@dataclass
599612
class Value:
600-
"""Original type: value = { ... }"""
613+
"""Original type: value = { ... }
614+
"""
601615

602616
features: List[str]
603617
proFeatures: Optional[ProFeatures] = None
@@ -656,7 +670,8 @@ def to_json_string(self, **kw: Any) -> str:
656670

657671
@dataclass
658672
class Uuid:
659-
"""Original type: uuid"""
673+
"""Original type: uuid
674+
"""
660675

661676
value: str
662677

@@ -677,7 +692,8 @@ def to_json_string(self, **kw: Any) -> str:
677692

678693
@dataclass
679694
class Sha256:
680-
"""Original type: sha256"""
695+
"""Original type: sha256
696+
"""
681697

682698
value: str
683699

@@ -698,7 +714,8 @@ def to_json_string(self, **kw: Any) -> str:
698714

699715
@dataclass
700716
class RuleStats:
701-
"""Original type: rule_stats = { ... }"""
717+
"""Original type: rule_stats = { ... }
718+
"""
702719

703720
ruleHash: str
704721
bytesScanned: int
@@ -733,7 +750,8 @@ def to_json_string(self, **kw: Any) -> str:
733750

734751
@dataclass
735752
class FileStats:
736-
"""Original type: file_stats = { ... }"""
753+
"""Original type: file_stats = { ... }
754+
"""
737755

738756
size: int
739757
numTimesScanned: int
@@ -776,7 +794,8 @@ def to_json_string(self, **kw: Any) -> str:
776794

777795
@dataclass
778796
class Performance:
779-
"""Original type: performance = { ... }"""
797+
"""Original type: performance = { ... }
798+
"""
780799

781800
numRules: Optional[int] = None
782801
numTargets: Optional[int] = None
@@ -829,7 +848,8 @@ def to_json_string(self, **kw: Any) -> str:
829848

830849
@dataclass
831850
class ParseStat:
832-
"""Original type: parse_stat = { ... }"""
851+
"""Original type: parse_stat = { ... }
852+
"""
833853

834854
targets_parsed: int
835855
num_targets: int
@@ -866,7 +886,8 @@ def to_json_string(self, **kw: Any) -> str:
866886

867887
@dataclass
868888
class Finding:
869-
"""Original type: finding = { ... }"""
889+
"""Original type: finding = { ... }
890+
"""
870891

871892
path: str
872893
line: int
@@ -906,7 +927,8 @@ def to_json_string(self, **kw: Any) -> str:
906927

907928
@dataclass
908929
class Mcp:
909-
"""Original type: mcp = { ... }"""
930+
"""Original type: mcp = { ... }
931+
"""
910932

911933
deployment_name: Optional[str] = None
912934
session_id: Optional[str] = None
@@ -1007,7 +1029,8 @@ def to_json_string(self, **kw: Any) -> str:
10071029

10081030
@dataclass
10091031
class Extension:
1010-
"""Original type: extension = { ... }"""
1032+
"""Original type: extension = { ... }
1033+
"""
10111034

10121035
machineId: Optional[str] = None
10131036
isNewAppInstall: Optional[bool] = None
@@ -1060,7 +1083,8 @@ def to_json_string(self, **kw: Any) -> str:
10601083

10611084
@dataclass
10621085
class Error:
1063-
"""Original type: error"""
1086+
"""Original type: error
1087+
"""
10641088

10651089
value: str
10661090

@@ -1081,7 +1105,8 @@ def to_json_string(self, **kw: Any) -> str:
10811105

10821106
@dataclass
10831107
class Errors:
1084-
"""Original type: errors = { ... }"""
1108+
"""Original type: errors = { ... }
1109+
"""
10851110

10861111
returnCode: Optional[int] = None
10871112
errors: Optional[List[Error]] = None
@@ -1114,7 +1139,8 @@ def to_json_string(self, **kw: Any) -> str:
11141139

11151140
@dataclass
11161141
class Environment:
1117-
"""Original type: environment = { ... }"""
1142+
"""Original type: environment = { ... }
1143+
"""
11181144

11191145
version: str
11201146
os: str
@@ -1175,7 +1201,8 @@ def to_json_string(self, **kw: Any) -> str:
11751201

11761202
@dataclass
11771203
class Datetime:
1178-
"""Original type: datetime"""
1204+
"""Original type: datetime
1205+
"""
11791206

11801207
value: str
11811208

@@ -1196,7 +1223,8 @@ def to_json_string(self, **kw: Any) -> str:
11961223

11971224
@dataclass
11981225
class Payload:
1199-
"""Original type: payload = { ... }"""
1226+
"""Original type: payload = { ... }
1227+
"""
12001228

12011229
event_id: Uuid
12021230
started_at: Datetime
@@ -1254,7 +1282,8 @@ def to_json_string(self, **kw: Any) -> str:
12541282

12551283
@dataclass
12561284
class Lang:
1257-
"""Original type: lang"""
1285+
"""Original type: lang
1286+
"""
12581287

12591288
value: str
12601289

semgrep_output_v1.jsonschema

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

semgrep_output_v1.proto

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)