JavaScript externs model StorageEvent() with no type argument

オープン 初心者向け
#22,632 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
84/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
javascript
領域
tooling, web-dev

調査の方向性

javascript/externs/web/webstorage.js から始め、StorageEvent コンストラクターと initStorageEvent の宣言を、issue に記載されている現在の Web IDL と比較します。文書化された型と省略可能な引数が表現されるように extern シグネチャを更新し、その後、示されている有効なコンストラクターの使用法がゼロ引数としてモデル化されなくなったことを確認します。

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

説明

Description

javascript/externs/web/webstorage.js still models StorageEvent as a zero-argument constructor:

/**
 * @see http://www.w3.org/TR/2011/CR-webstorage-20111208/#the-storage-event
 * @extends {Event}
 * @constructor
 */
function StorageEvent() {}

Current HTML (the-storageevent-interface) defines:

constructor(DOMString type, optional StorageEventInit eventInitDict = {});

new StorageEvent('storage', { key, newValue, ... }) is valid in browsers (constructor available since 2018). CodeQL 2.27.0 reported a false positive on a standards-conforming new StorageEvent('storage', { ... }) call used in a synthetic StorageEvent test.

initStorageEvent in the same file also follows the old required-argument list; the spec method has optional arguments after type.

I searched this tracker for StorageEvent / StorageEventInit / webstorage externs and did not find an existing issue.

Reproduction

  1. Analyze JavaScript that constructs new StorageEvent('storage', { key: 'k', newValue: 'v' }).
  2. Observe a CodeQL alert that treats the constructor as taking no parameters.

Expected

Externs should match the current constructor (type plus optional StorageEventInit) so valid Web IDL usage is not flagged.

This is a modeling/false-positive report only. No exploit is claimed.

主要言語
CodeQL
スター
10.1k
フォーク
2.1k
平均マージ
2日 11時間
マージ済み PR(30日)
129

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

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

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

github/codeql のほかの issue

github/codeql の issue をすべて見る

似ている issue

DevTools の issue をもっと見る

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

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