-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
38df82e
commit de540ac
Showing
9 changed files
with
229 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/docs/guide/usage/linter/rules/eslint/no-extend-native.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<!-- This file is auto-generated by tasks/website/src/linter/rules/doc_page.rs. Do not edit it manually. --> | ||
|
||
# eslint/no-extend-native <Badge type="info" text="Suspicious" /> | ||
|
||
<div class="rule-meta"> | ||
</div> | ||
|
||
### What it does | ||
|
||
Prevents extending native global objects such as `Object`, `String`, or `Array` with new | ||
properties. | ||
|
||
### Why is this bad? | ||
|
||
Extending native objects can cause unexpected behavior and conflicts with other code. | ||
|
||
For example: | ||
|
||
```js | ||
// Adding a new property, which might seem okay | ||
Object.prototype.extra = 55; | ||
|
||
// Defining a user object | ||
const users = { | ||
1: "user1", | ||
2: "user2", | ||
}; | ||
|
||
for (const id in users) { | ||
// This will print "extra" as well as "1" and "2": | ||
console.log(id); | ||
} | ||
``` | ||
|
||
### Examples | ||
|
||
Examples of **incorrect** code for this rule: | ||
|
||
```js | ||
Object.prototype.p = 0; | ||
Object.defineProperty(Array.prototype, "p", { value: 0 }); | ||
``` | ||
|
||
Examples of **correct** code for this rule: | ||
|
||
```js | ||
x.prototype.p = 0; | ||
Object.defineProperty(x.prototype, "p", { value: 0 }); | ||
``` | ||
|
||
## References | ||
|
||
- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/eslint/no_extend_native.rs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/docs/guide/usage/linter/rules/eslint/no-unexpected-multiline.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<!-- This file is auto-generated by tasks/website/src/linter/rules/doc_page.rs. Do not edit it manually. --> | ||
|
||
# eslint/no-unexpected-multiline <Badge type="info" text="Suspicious" /> | ||
|
||
<div class="rule-meta"> | ||
<Alert class="fix" type="info"> | ||
<span class="emoji">⚠️🛠️️</span> A dangerous auto-fix is available for this rule. | ||
</Alert> | ||
</div> | ||
|
||
### What it does | ||
|
||
In most cases, semicolons are not required in JavaScript in order for code to be parsed | ||
and executed as expected. Typically this occurs because semicolons are automatically | ||
inserted based on a fixed set of rules. This rule exists to detect those cases where a semicolon | ||
is NOT inserted automatically, and may be parsed differently than expected. | ||
|
||
### Why is this bad? | ||
|
||
Code that has unexpected newlines may be parsed and executed differently than what the | ||
developer intended. This can lead to bugs that are difficult to track down. | ||
|
||
### Examples | ||
|
||
Examples of **incorrect** code for this rule: | ||
|
||
```js | ||
var a = b(x || y).doSomething(); | ||
|
||
var a = b[(a, b, c)].forEach(doSomething); | ||
|
||
let x = (function () {})`hello`; | ||
|
||
foo / bar / g.test(baz); | ||
``` | ||
|
||
Examples of **correct** code for this rule: | ||
|
||
```js | ||
var a = b; | ||
(x || y).doSomething(); | ||
|
||
var a = b; | ||
[a, b, c].forEach(doSomething); | ||
|
||
let x = function () {}; | ||
`hello`; | ||
|
||
foo; | ||
/bar/g.test(baz); | ||
``` | ||
|
||
## References | ||
|
||
- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/eslint/no_unexpected_multiline.rs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<!-- This file is auto-generated by tasks/website/src/linter/rules/doc_page.rs. Do not edit it manually. --> | ||
|
||
# security/api-keys <Badge type="info" text="Correctness" /> | ||
|
||
<div class="rule-meta"> | ||
</div> | ||
|
||
### What it does | ||
|
||
Disallows hard-coded API keys and other credentials. | ||
|
||
### Why is this bad? | ||
|
||
Hard-coding API keys and committing them to source control is a serious | ||
security risk. | ||
|
||
1. If your code is leaked, attackers can use your API keys to access your | ||
services and data. | ||
2. Accidental bundling of API keys can lead them to be exposed publicly | ||
in your website, compriming your services. | ||
3. Any developer or contractor you hire will have access to your | ||
services, even after they lose access to your codebase. | ||
4. Even after being deleted, they will be visible in your git repo's | ||
commit history. | ||
5. Key rotation requires a code change and redeployment, and can | ||
therefore not be handled by security teams or by automated systems. | ||
6. Many, many more reasons. | ||
|
||
```ts | ||
const API_KEY = "abcdef123456"; | ||
const data = await fetch("/api/some/endpoint", { | ||
headers: { | ||
Authorization: `Bearer ${API_KEY}`, | ||
}, | ||
}); | ||
``` | ||
|
||
### What To Do Instead | ||
|
||
:::warning | ||
The Oxc team are not security experts. We do not endorse any particular | ||
key management service or strategy. Do your research and choose the best | ||
solution/architecture for your use case. | ||
::: | ||
|
||
One possible alternative is to store secrets in a secure secrets manager | ||
(such as [AWS | ||
KMS](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/kms/), | ||
[HashiCorp Vault](https://github.com/nodevault/node-vault/tree/master), | ||
[Pangea](https://pangea.cloud/docs/sdk/js/vault#retrieve), etc.) and | ||
request them when your application starts (e.g. a Docker container, an | ||
EC2). | ||
|
||
### Examples | ||
|
||
Examples of **incorrect** code for this rule: | ||
|
||
```js | ||
const AWS_ACCESS_KEY_ID = "AKIA1234X678C123B567"; | ||
const OPENAI_API_KEY = "sk_test_1234567890"; | ||
``` | ||
|
||
Examples of **correct** code for this rule: | ||
|
||
```js | ||
const AWS_ACCESS_KEY_ID = process.env.AWS_ACCESS_KEY_ID; | ||
const OPENAI_API_KEY = await getSecret("open-ai-api-key"); | ||
``` | ||
|
||
## References | ||
|
||
- [Rule Source](https://github.com/oxc-project/oxc/blob/main/crates/oxc_linter/src/rules/security/api_keys/mod.rs) |