semgrep / pfff

pfff is mainly an OCaml API to write static analysis, dynamic analysis, code visualizations, code navigations, or style-preserving source-to-source transformations such as refactorings on source code.
https://semgrep.dev
Other
186 stars 29 forks source link

feat(js): added decorated fields to semgrep patterns #543

Closed brandonspark closed 2 years ago

brandonspark commented 2 years ago

What: Added the ability to parse decorated class fields, which look like @Input() field: string;. Notably, these are not methods, as they are not functions, which was what I added last time.

Test plan: We now parse @$DEC() $INPUT: string as:

Fld(
  F(
    DefStmt(
      ({
        name=EN(
               Id(("$INPUT", ()),
                 {id_info_id=3; id_hidden=false; id_resolved=Ref(None);
                  id_type=Ref(None); id_svalue=Ref(None); }));
        attrs=[NamedAttr((),
                 Id(("$DEC", ()),
                   {id_info_id=1; id_hidden=false; id_resolved=Ref(None);
                    id_type=Ref(None); id_svalue=Ref(None); }), [])];
        tparams=[]; },
       VarDef(
         {vinit=None;
          vtype=Some({t_attrs=[];
                      t=TyN(
                          Id(("string", ()),
                            {id_info_id=2; id_hidden=false;
                             id_resolved=Ref(None); id_type=Ref(None);
                             id_svalue=Ref(None); }));
                      });
          })))))

Security