Skip to content

Commit 8a7444c

Browse files
authored
chore(mcp): add deployment name field (#415)
- [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! - [ ] Any accompanying changes in `semgrep-proprietary` are approved and ready to merge once this PR is merged
1 parent 302f60a commit 8a7444c

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

semgrep_metrics.atd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ type finding = {
280280

281281

282282
type mcp = {
283+
?deployment_name <ocaml mutable>: string option;
283284
?session_id <ocaml mutable>: string option;
284285
?num_skipped_rules <ocaml mutable>: int option;
285286
?rules <ocaml mutable>: string list option;

semgrep_metrics.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,7 @@ def to_json_string(self, **kw: Any) -> str:
908908
class Mcp:
909909
"""Original type: mcp = { ... }"""
910910

911+
deployment_name: Optional[str] = None
911912
session_id: Optional[str] = None
912913
num_skipped_rules: Optional[int] = None
913914
rules: Optional[List[str]] = None
@@ -925,6 +926,7 @@ class Mcp:
925926
def from_json(cls, x: Any) -> 'Mcp':
926927
if isinstance(x, dict):
927928
return cls(
929+
deployment_name=_atd_read_string(x['deployment_name']) if 'deployment_name' in x else None,
928930
session_id=_atd_read_string(x['session_id']) if 'session_id' in x else None,
929931
num_skipped_rules=_atd_read_int(x['num_skipped_rules']) if 'num_skipped_rules' in x else None,
930932
rules=_atd_read_list(_atd_read_string)(x['rules']) if 'rules' in x else None,
@@ -943,6 +945,8 @@ def from_json(cls, x: Any) -> 'Mcp':
943945

944946
def to_json(self) -> Any:
945947
res: Dict[str, Any] = {}
948+
if self.deployment_name is not None:
949+
res['deployment_name'] = _atd_write_string(self.deployment_name)
946950
if self.session_id is not None:
947951
res['session_id'] = _atd_write_string(self.session_id)
948952
if self.num_skipped_rules is not None:

0 commit comments

Comments
 (0)