text_search: one-letter or wildcard queries load almost the whole database (90s+), and the search box doesn't encode the term
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 70/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- python, react, typescript
- 領域
- backend, frontend, performance
調査の方向性
application/database/db.py の Node_collection.text_search() から始めてください。ここでは用語が LIKE パターンに6回補間されています。% と _ のエスケープ、ファジー部分の最小長、行数制限を追加してください。次に SearchBar.tsx と Search.tsx のクライアントを修正し、用語を encodeURIComponent で包んでから history.push してください。/rest/v1/text_search を session、e、%、_ で実行して時間を計測し、/search/C%23 がバックエンドにそのまま到達することを確認してください。この issue は修正の選択肢をオープンにしているため、まず maintainer とアプローチについて合意してください。
索引モデルが issue の本文から書いたものです。
説明
Problem
A very short search makes /rest/v1/text_search return almost everything in the database and takes minutes.
Tested on my local setup (staging at d9514e52, full upstream sync: 522 CREs, 2841 nodes):
| Request | Time | Response |
|---|---|---|
text_search?text=session |
2.3 s | 215 KB |
text_search?text=e |
89 s | 8.4 MB, 3311 of 3363 rows |
text_search?text=% |
no response after 180 s | - |
text_search?text=_ |
no response after 180 s | - |
In the UI, searching for e loads for a long time and then shows "The document could not be loaded".
I did not test this on opencre.org on purpose, so I don't load the live server.
Cause
In Node_collection.text_search() (application/database/db.py), the fuzzy search does:
args = [f"%{search_term}%", "", "", "", "", ""]
- The term is used directly in
LIKE, so%and_are not escaped.text=%becomes%%%and matches every row. - There is no limit on results, so a common letter like
ematches almost all nodes and CREs. - The 6 permutations run one query per column (name, section, subsection, link, description, sectionID), and each one loads all of its matches.
Because /rest/v1/text_search is public, a few of these requests can keep the server busy.
Related: the search box doesn't encode the term
SearchBar.tsx and Search.tsx do:
history.push(`${SEARCH}/${term}`);
The term is not passed through encodeURIComponent, so:
%throwsUncaught URIError: Pathname "/search/%" could not be decodedand nothing happensC#becomes/search/C#, so it searches forC, which triggers the slow one-letter search above
Possible fixes
- Escape
%and_in the search term before building theLIKEpattern - Require a minimum length for the fuzzy part (for example 2 or 3 characters)
- Limit the number of fuzzy results
- Encode the term in the search box with
encodeURIComponent
I'm happy to work on this. Which of these would you like, and should the PR target main or staging?
- 主要言語
- Python
- スター
- 216
- フォーク
- 173
- 平均マージ
- 1日 21時間
- マージ済み PR(30日)
- 21
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
OWASP/OpenCRE のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
OWASP/OpenCRE#1232 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
OWASP/OpenCRE#1228 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Incorrect inverse relationship type in CRE internal-link export再び着手できるかも @saicharan-r02 が 8 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
OWASP/OpenCRE#1215 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
Map Analysis continues polling after a background job fails対応中かも @abhi2005-bit が 10 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
OWASP/OpenCRE#1211 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
MarkdownDocSerializer.post_process escapes '\<' to '\<', rendering literal '<' in CommonMarkオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
docling-project/docling-core#1067 ·
メンテナーはふだん 3 日以内に返信
-
correction metadata
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
acl-org/acl-anthology#11101 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] crewai tool create/install/login exit 0 when they fail対応中かも @Kiko0301 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
vllm-project/compressed-tensors#1033 ·
メンテナーはふだん 3 日以内に返信
-
chore kaizen ui-rewrite
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
IBM/mcp-context-forge#7681 ·
メンテナーはふだん 2 日以内に返信