Semgrep: Typescript not recognized

Created on 21 Sep 2020  路  4Comments  路  Source: returntocorp/semgrep

Describe the bug
Only ts is working for typescript. Neither tsx nor typescript are recognized, as they are supposed to be.

$ semgrep -f mysemgrep
error: invalid language
14 |     message: "onDestroy not implemented"
15 |     languages: [typescript]
   |                ^^^^^^^^^^^^
16 |     severity: ERROR

unsupported language typescript

Reason--there is a missing comma:
https://github.com/returntocorp/semgrep/blob/d3fe469c7edc44f179cf7754836ed5f34d073614/semgrep/semgrep/target_manager.py#L61

Change this:

elif language in {"ts", "tsx" "typescript"}:

To this:

elif language in {"ts", "tsx", "typescript"}:

Most helpful comment

Ahah, semgrep can find this bug now!

  • /home/pad/semgrep/_build/default/bin/Main.exe -lang python -e {..., "..." "...", ...} semgrep/
    semgrep/semgrep/target_manager.py:61
    elif language in {"ts", "tsx" "typescript"}:
    semgrep/semgrep/target_manager.py:61
    elif language in {"ts", "tsx" "typescript"}:

All 4 comments

Ahah, semgrep can find this bug now!

  • /home/pad/semgrep/_build/default/bin/Main.exe -lang python -e {..., "..." "...", ...} semgrep/
    semgrep/semgrep/target_manager.py:61
    elif language in {"ts", "tsx" "typescript"}:
    semgrep/semgrep/target_manager.py:61
    elif language in {"ts", "tsx" "typescript"}:

@mschwager @minusworld a new python rule to put in semgrep-rules/ ?
{..., "..." "....", ...} is probably a bug with a missing comma typo.

I'll add it in the local semgrep.yml

Should work now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MCOffSec picture MCOffSec  路  3Comments

ajinabraham picture ajinabraham  路  6Comments

brendongo picture brendongo  路  5Comments

ajinabraham picture ajinabraham  路  6Comments

rttwge picture rttwge  路  5Comments