github / github/codeql-cli-binaries

Add `string` predicates `startsWith`, `endsWith` and `contains`

未關閉
#78 2 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
CLI
主要語言
沒有語言資料
星號
1k
分支
184
PR 合併指標
30 天內沒有已合併 PR

描述

What do you think about adding predicates to the CodeQL type `string` for determining whether a string has a given prefix or suffix or contains a substring? For example `startsWith(string)`, `endsWith(string)` and `contains(string)`.
Currently the workarounds are using `indexOf(...) = 0` or `matches(...%)` (which seems to be faster than `indexOf`, see https://github.com/github/codeql/issues/6479#issuecomment-900081363). However, these predicates do not convey the intention as clearly, might not be that performant and for `matches` one must take care not to accidentally use `%`or `_` where the intention was to match them literally.

In the github/codeql repository (at https://github.com/github/codeql/commit/39533317ffbeb6224d049de22fc182d8eeea4b61) there are at least:
- 196 cases where `startsWith` could be used
(I searched for the regex `matches\("[^%_]*%"\)` in CodeQL source files)
- 72 cases where `endsWith` could be used
(I searched for the regex `matches\("%[^%_]*"\)` in CodeQL source files)

貢獻指南

開啟貢獻指南

研究方向

The issue proposes adding startsWith, endsWith, and contains predicates to the CodeQL string type, but names no source files, tests, or implementation entry points. Begin by locating the string type implementation and its tests; done means the predicates are available and cover prefix, suffix, and substring checks without relying on indexOf or matches workarounds.

由索引模型根據 Issue 內容生成。

評估

領域
devtools
Issue 類型
功能
難度
5/5
預估耗時
一週以上
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。