跳转到内容

useIframeSandbox

此内容尚不支持你的语言。

biome.json
{
"linter": {
"rules": {
"nursery": {
"useIframeSandbox": "error"
}
}
}
}

Enforce the ‘sandbox’ attribute for ‘iframe’ elements.

The sandbox attribute enables an extra set of restrictions for the content in the iframe. Using the sandbox attribute is considered a good security practice.

See the Mozilla docs for details.

<iframe src="https://example.com"></iframe>
code-block.html:1:1 lint/nursery/useIframeSandbox ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Iframe doesn’t have the sandbox attribute.

> 1 │ <iframe src=“https://example.com&quot;&gt;&lt;/iframe>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │

The sandbox attribute enables an extra set of restrictions for the content in the iframe, protecting against malicious scripts and other security threats.

Provide a sandbox attribute when using iframe elements.

This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

<iframe src="https://example.com" sandbox="allow-popups"></iframe>