An ESLint plugin designed to identify and flag potential AI ethics and security vulnerabilities in your codebase and package.json. Helps ensure responsible AI development by detecting issues like biased language, unconsented data collection, hardcoded sec
npm install eslint-plugin-ethixAn ESLint plugin to identify AI ethics and security red-flags in JavaScript repositories.
First, install ESLint:
``bash`
npm i eslint --save-dev
Next, install eslint-plugin-ethix:
`bash`
npm install eslint-plugin-ethix --save-dev
Add ethix to the plugins section of your .eslintrc configuration file. You can then configure the rules you want to use under the rules section.
`json`
{
"plugins": [
"ethix"
],
"rules": {
"ethix/no-hardcoded-secrets": "error",
"ethix/no-facial-analysis-libs": "warn",
"ethix/no-opaque-ai-models": "warn"
}
}
Alternatively, you can use the recommended configuration:
`json`
{
"extends": [
"plugin:ethix/recommended"
]
}
Here's an example of how eslint-plugin-ethix can help you identify potential issues:
`javascript
// Example of a hardcoded secret (will be flagged by no-hardcoded-secrets)
const API_KEY = "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
// Example of using a facial analysis library (will be flagged by no-facial-analysis-libs)
import { FacialRecognizer } from 'some-facial-analysis-lib';
// Example of potentially opaque AI model usage (will be flagged by no-opaque-ai-models)
const model = new OpaqueAIModel();
// Example of unconsented data collection (will be flagged by no-unconsented-data-collection)
navigator.geolocation.getCurrentPosition(successCallback, errorCallback);
// Example of sensitive API key in URL (will be flagged by no-sensitive-api-keys-in-url)
const url = https://api.example.com/data?key=YOUR_API_KEY_HERE;
// Example of biased language (will be flagged by no-biased-language)
// This code is for the 'master' branch.
const user = "he is a good guy";
`
* no-hardcoded-secrets: Disallows hardcoded secrets (e.g., API keys, passwords).no-facial-analysis-libs
* : Disallows the use of facial analysis libraries.no-opaque-ai-models
* : Warns about the use of potentially opaque AI models or libraries.no-unconsented-data-collection
* : Flags usage of APIs that typically require user consent for data collection (e.g., geolocation, camera, microphone).no-sensitive-api-keys-in-url
* : Disallows sensitive API keys from being hardcoded directly into URLs.no-biased-language
* : Flags potentially biased or discriminatory language in comments and string literals (not included in recommended config).
To run tests:
`bash``
npm test