Skip to main content
interlace
Plugin: gemini-securityRules

no-disabled-safety-settings

Forbid disabling Gemini harm-category filters

Forbid disabling Gemini harm-category filters.

Why

threshold: BLOCK_NONE (or OFF) switches off the model's content filter for that harm category. Where output reaches users โ€” or feeds another system โ€” that removes the only server-side control over what the model may emit. Each disabled category is reported separately.

Both the string form and the enum form (HarmBlockThreshold.BLOCK_NONE) are detected, directly or through a same-file const.

threshold: 'OFF' is also how a circuit breaker, a log level or a lint severity is written, and a file that calls Gemini can hold all of those. So the value must be the SDK's own enum member โ€” HarmBlockThreshold resolved through its import, renamed or namespaced โ€” or sit in the SDK's SafetySetting shape: a category beside it, or an enclosing safetySettings: [ โ€ฆ ].

Incorrect

import { GoogleGenAI } from '@google/genai';

const config = {
  safetySettings: [
    { category: 'HARM_CATEGORY_HARASSMENT', threshold: 'BLOCK_NONE' },
  ],
};

Correct

const config = {
  safetySettings: [
    {
      category: 'HARM_CATEGORY_HARASSMENT',
      threshold: 'BLOCK_MEDIUM_AND_ABOVE',
    },
  ],
};

When not to use it

Red-teaming or eval harnesses that deliberately probe unfiltered output. Disable the rule for those files specifically rather than globally.

Use this rule

npm install -D oxlint-plugin-gemini-security
.oxlintrc.json
{  "jsPlugins": ["oxlint-plugin-gemini-security"],  "rules": {    "gemini-security/no-disabled-safety-settings": "error"  }}
vite.config.ts
import { defineConfig } from 'vite-plus';export default defineConfig({  lint: {    jsPlugins: ['oxlint-plugin-gemini-security'],    rules: {      'gemini-security/no-disabled-safety-settings': 'error',    },  },});

oxlint-plugin-gemini-security re-exports eslint-plugin-gemini-security/oxlint: the same rules under the same IDs, and no ESLint install. Why oxlint.

Did this rule catch something? Star the repo to get new CWE coverage as we ship it โ€” or follow the AI-code-security benchmarks behind these rules.