github / github/codeql-cli-binaries

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

オープン
#78 コメント 2 件 リアクション 1 件 担当者 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)

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

この issue では、CodeQL の string 型に startsWith、endsWith、contains 述語を追加することが提案されていますが、ソースファイル、テスト、実装のエントリポイントは指定されていません。まず string 型の実装とそのテストを見つけてください。述語が利用可能になり、indexOf や matches の代替手段に頼らずに、プレフィックス、サフィックス、部分文字列のチェックをカバーできれば完了です。

索引モデルが issue の本文から書いたものです。

評価

領域
devtools
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。