playwright-smart-test 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SECURITY.md +41 -0
- package/dist/cli/index.js +24 -3
- package/dist/reporters/github-commenter.d.ts +26 -0
- package/dist/reporters/github-commenter.js +145 -0
- package/dist/reporters/github-reporter.js +6 -1
- package/dist/reporters/terminal-reporter.js +6 -1
- package/node_modules/ecdsa-sig-formatter/node_modules/safe-buffer/LICENSE +21 -0
- package/node_modules/ecdsa-sig-formatter/node_modules/safe-buffer/README.md +49 -0
- package/node_modules/ecdsa-sig-formatter/node_modules/safe-buffer/index.d.ts +2 -0
- package/node_modules/ecdsa-sig-formatter/node_modules/safe-buffer/index.js +17 -0
- package/node_modules/ecdsa-sig-formatter/node_modules/safe-buffer/package.json +36 -0
- package/node_modules/jwa/node_modules/safe-buffer/LICENSE +21 -0
- package/node_modules/jwa/node_modules/safe-buffer/LICENSE.original +21 -0
- package/node_modules/jwa/node_modules/safe-buffer/README.md +49 -0
- package/node_modules/jwa/node_modules/safe-buffer/index.d.ts +2 -0
- package/node_modules/jwa/node_modules/safe-buffer/index.js +17 -0
- package/node_modules/jwa/node_modules/safe-buffer/package.json +36 -0
- package/node_modules/jws/node_modules/safe-buffer/LICENSE +21 -0
- package/node_modules/jws/node_modules/safe-buffer/LICENSE.original +21 -0
- package/node_modules/jws/node_modules/safe-buffer/README.md +49 -0
- package/node_modules/jws/node_modules/safe-buffer/index.d.ts +2 -0
- package/node_modules/jws/node_modules/safe-buffer/index.js +17 -0
- package/node_modules/jws/node_modules/safe-buffer/package.json +36 -0
- package/package.json +3 -2
- package/node_modules/safe-buffer/README.md +0 -584
- package/node_modules/safe-buffer/index.d.ts +0 -187
- package/node_modules/safe-buffer/index.js +0 -65
- package/node_modules/safe-buffer/package.json +0 -51
- /package/node_modules/{safe-buffer/LICENSE → ecdsa-sig-formatter/node_modules/safe-buffer/LICENSE.original} +0 -0
package/SECURITY.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
| Version | Supported |
|
|
6
|
+
|---------|-----------|
|
|
7
|
+
| 1.x.x | ✅ Active |
|
|
8
|
+
|
|
9
|
+
## Reporting a Vulnerability
|
|
10
|
+
|
|
11
|
+
Please **do not** open a public GitHub issue for security vulnerabilities.
|
|
12
|
+
|
|
13
|
+
Use [GitHub Private Vulnerability Reporting](https://github.com/Ujjwal-S-S/playwright-smart-test/security/advisories/new) or email the maintainer directly. We will investigate all reports but cannot guarantee a specific response or fix timeline.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## What This Package Does
|
|
18
|
+
|
|
19
|
+
`playwright-smart-test` is a **CLI dev tool** — it runs locally or in CI pipelines to analyze a git diff and select the minimal set of Playwright tests to run. It is **never installed as a runtime server-side dependency** in production applications.
|
|
20
|
+
|
|
21
|
+
Key behaviours:
|
|
22
|
+
|
|
23
|
+
- Reads your local git history (`git diff`) to detect changed files
|
|
24
|
+
- Scans your local `tests/` directory to build a test catalog
|
|
25
|
+
- Optionally calls the Google Gemini API to perform AI-powered impact analysis
|
|
26
|
+
- Spawns `playwright test` with the selected test files
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Dependency Chain
|
|
31
|
+
|
|
32
|
+
Direct runtime dependencies:
|
|
33
|
+
|
|
34
|
+
| Package | Purpose |
|
|
35
|
+
|---------|---------|
|
|
36
|
+
| `@google/genai` | Gemini API client — used only when an API key is configured |
|
|
37
|
+
| `commander` | CLI argument parsing |
|
|
38
|
+
| `dotenv` | Loads `.env` file for the API key |
|
|
39
|
+
| `glob` | File pattern matching to find spec files |
|
|
40
|
+
| `picocolors` | Terminal colour output |
|
|
41
|
+
| `zod` | Config and AI response schema validation |
|
package/dist/cli/index.js
CHANGED
|
@@ -9,12 +9,13 @@ import { TestCatalogIndexer } from '../catalog/test-catalog.js';
|
|
|
9
9
|
import { TestSelector } from '../selector/test-selector.js';
|
|
10
10
|
import { TerminalReporter } from '../reporters/terminal-reporter.js';
|
|
11
11
|
import { GitHubReporter } from '../reporters/github-reporter.js';
|
|
12
|
+
import { GitHubCommenter } from '../reporters/github-commenter.js';
|
|
12
13
|
import { PlaywrightRunner } from '../runner/playwright-runner.js';
|
|
13
14
|
const program = new Command();
|
|
14
15
|
program
|
|
15
16
|
.name('playwright-smart-test')
|
|
16
17
|
.description('AI-Powered Smart Regression Test Selection Agent for Playwright')
|
|
17
|
-
.version('1.0.
|
|
18
|
+
.version('1.0.6');
|
|
18
19
|
async function executeAnalysis(options) {
|
|
19
20
|
const cwd = options.cwd ? path.resolve(options.cwd) : process.cwd();
|
|
20
21
|
const config = loadConfig(cwd, options.config);
|
|
@@ -73,10 +74,15 @@ program
|
|
|
73
74
|
.option('-c, --config <path>', 'Path to custom config file')
|
|
74
75
|
.option('--cwd <dir>', 'Working directory', process.cwd())
|
|
75
76
|
.option('--dry-run', 'Print the command without executing')
|
|
77
|
+
.option('--comment', 'Automatically post or update PR comment and step summary on GitHub')
|
|
76
78
|
.action(async (options) => {
|
|
77
79
|
try {
|
|
78
80
|
const { result, cwd } = await executeAnalysis(options);
|
|
79
81
|
TerminalReporter.report(result);
|
|
82
|
+
if (options.comment) {
|
|
83
|
+
const markdown = GitHubReporter.generateMarkdown(result);
|
|
84
|
+
await GitHubCommenter.postOrUpdateComment(markdown);
|
|
85
|
+
}
|
|
80
86
|
if (options.dryRun) {
|
|
81
87
|
console.log(pc.yellow(`[Dry-run] Would execute: ${result.playwrightCommand}`));
|
|
82
88
|
return;
|
|
@@ -95,17 +101,32 @@ program
|
|
|
95
101
|
});
|
|
96
102
|
program
|
|
97
103
|
.command('comment')
|
|
98
|
-
.description('Generate GitHub PR comment
|
|
104
|
+
.description('Generate and post GitHub PR comment report')
|
|
99
105
|
.option('-b, --base <ref>', 'Base git commit/branch')
|
|
100
106
|
.option('-h, --head <ref>', 'Head git commit/branch')
|
|
101
107
|
.option('--staged', 'Analyze only staged changes')
|
|
102
108
|
.option('-c, --config <path>', 'Path to custom config file')
|
|
103
109
|
.option('--cwd <dir>', 'Working directory', process.cwd())
|
|
110
|
+
.option('--pr <number>', 'Explicit pull request number')
|
|
111
|
+
.option('--repo <owner/repo>', 'Explicit GitHub repository')
|
|
112
|
+
.option('--token <token>', 'Explicit GitHub Token')
|
|
113
|
+
.option('--stdout', 'Only output markdown to stdout without attempting GitHub API post')
|
|
104
114
|
.action(async (options) => {
|
|
105
115
|
try {
|
|
106
116
|
const { result } = await executeAnalysis(options);
|
|
107
117
|
const markdown = GitHubReporter.generateMarkdown(result);
|
|
108
|
-
|
|
118
|
+
if (options.stdout) {
|
|
119
|
+
console.log(markdown);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const posted = await GitHubCommenter.postOrUpdateComment(markdown, {
|
|
123
|
+
pr: options.pr ? parseInt(options.pr, 10) : undefined,
|
|
124
|
+
repo: options.repo,
|
|
125
|
+
token: options.token,
|
|
126
|
+
});
|
|
127
|
+
if (!posted) {
|
|
128
|
+
console.log(markdown);
|
|
129
|
+
}
|
|
109
130
|
}
|
|
110
131
|
catch (err) {
|
|
111
132
|
console.error(pc.red(`Error: ${err instanceof Error ? err.message : String(err)}`));
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface GitHubCommentOptions {
|
|
2
|
+
pr?: number;
|
|
3
|
+
repo?: string;
|
|
4
|
+
token?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class GitHubCommenter {
|
|
7
|
+
/**
|
|
8
|
+
* Retrieves GitHub authentication token from environment or GitHub CLI
|
|
9
|
+
*/
|
|
10
|
+
static getAuthToken(overrideToken?: string): string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Identifies repository and PR number from environment or GitHub Actions event payload
|
|
13
|
+
*/
|
|
14
|
+
static getPRContext(options?: GitHubCommentOptions): {
|
|
15
|
+
repo?: string;
|
|
16
|
+
prNumber?: number;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Appends report to GitHub Actions Step Summary if running in CI
|
|
20
|
+
*/
|
|
21
|
+
static writeStepSummary(markdown: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* Posts or updates the comment directly on the GitHub PR
|
|
24
|
+
*/
|
|
25
|
+
static postOrUpdateComment(markdown: string, options?: GitHubCommentOptions): Promise<boolean>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { execSync } from 'node:child_process';
|
|
3
|
+
import pc from 'picocolors';
|
|
4
|
+
export class GitHubCommenter {
|
|
5
|
+
/**
|
|
6
|
+
* Retrieves GitHub authentication token from environment or GitHub CLI
|
|
7
|
+
*/
|
|
8
|
+
static getAuthToken(overrideToken) {
|
|
9
|
+
if (overrideToken)
|
|
10
|
+
return overrideToken;
|
|
11
|
+
if (process.env.GITHUB_TOKEN)
|
|
12
|
+
return process.env.GITHUB_TOKEN;
|
|
13
|
+
if (process.env.GH_TOKEN)
|
|
14
|
+
return process.env.GH_TOKEN;
|
|
15
|
+
// Fallback: check if GitHub CLI is authenticated in the current runner
|
|
16
|
+
try {
|
|
17
|
+
const output = execSync('gh auth token', { stdio: ['pipe', 'pipe', 'ignore'], encoding: 'utf8' }).trim();
|
|
18
|
+
if (output)
|
|
19
|
+
return output;
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
// gh cli not installed or not authenticated
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Identifies repository and PR number from environment or GitHub Actions event payload
|
|
28
|
+
*/
|
|
29
|
+
static getPRContext(options) {
|
|
30
|
+
let repo = options?.repo || process.env.GITHUB_REPOSITORY;
|
|
31
|
+
let prNumber = options?.pr;
|
|
32
|
+
if (!prNumber && process.env.GITHUB_EVENT_PATH && fs.existsSync(process.env.GITHUB_EVENT_PATH)) {
|
|
33
|
+
try {
|
|
34
|
+
const eventData = JSON.parse(fs.readFileSync(process.env.GITHUB_EVENT_PATH, 'utf8'));
|
|
35
|
+
if (eventData.pull_request?.number) {
|
|
36
|
+
prNumber = eventData.pull_request.number;
|
|
37
|
+
}
|
|
38
|
+
else if (eventData.issue?.number) {
|
|
39
|
+
prNumber = eventData.issue.number;
|
|
40
|
+
}
|
|
41
|
+
else if (eventData.number) {
|
|
42
|
+
prNumber = eventData.number;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
// failed to parse event payload
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return { repo, prNumber };
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Appends report to GitHub Actions Step Summary if running in CI
|
|
53
|
+
*/
|
|
54
|
+
static writeStepSummary(markdown) {
|
|
55
|
+
const summaryFile = process.env.GITHUB_STEP_SUMMARY;
|
|
56
|
+
if (summaryFile) {
|
|
57
|
+
try {
|
|
58
|
+
fs.appendFileSync(summaryFile, `\n${markdown}\n`, 'utf8');
|
|
59
|
+
console.log(pc.green('✓ Report added to GitHub Actions Step Summary.'));
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// ignore summary write error
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Posts or updates the comment directly on the GitHub PR
|
|
68
|
+
*/
|
|
69
|
+
static async postOrUpdateComment(markdown, options) {
|
|
70
|
+
// 1. Always append to GitHub Step Summary if running in Actions
|
|
71
|
+
this.writeStepSummary(markdown);
|
|
72
|
+
const token = this.getAuthToken(options?.token);
|
|
73
|
+
const { repo, prNumber } = this.getPRContext(options);
|
|
74
|
+
if (!token) {
|
|
75
|
+
console.log(pc.yellow('ℹ No GITHUB_TOKEN or gh CLI auth detected. Skipped posting PR comment (printed to console).'));
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
if (!repo || !prNumber) {
|
|
79
|
+
console.log(pc.yellow(`ℹ Not running in a pull request context (repo=${repo || 'none'}, pr=${prNumber || 'none'}). Skipped posting comment.`));
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
const apiUrl = process.env.GITHUB_API_URL || 'https://api.github.com';
|
|
83
|
+
const commentHeaderTag = '## 🤖 Playwright Smart Regression Selection Report';
|
|
84
|
+
try {
|
|
85
|
+
// 2. Fetch existing comments to see if we should update or create
|
|
86
|
+
const listRes = await fetch(`${apiUrl}/repos/${repo}/issues/${prNumber}/comments?per_page=100`, {
|
|
87
|
+
headers: {
|
|
88
|
+
Authorization: `Bearer ${token}`,
|
|
89
|
+
Accept: 'application/vnd.github+json',
|
|
90
|
+
'User-Agent': 'playwright-smart-test',
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
if (!listRes.ok) {
|
|
94
|
+
console.error(pc.red(`Failed to fetch existing PR comments: ${listRes.status} ${listRes.statusText}`));
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
const comments = (await listRes.json());
|
|
98
|
+
const existingComment = comments.find((c) => c.body && c.body.includes(commentHeaderTag));
|
|
99
|
+
if (existingComment) {
|
|
100
|
+
// Update existing comment
|
|
101
|
+
const updateRes = await fetch(`${apiUrl}/repos/${repo}/issues/comments/${existingComment.id}`, {
|
|
102
|
+
method: 'PATCH',
|
|
103
|
+
headers: {
|
|
104
|
+
Authorization: `Bearer ${token}`,
|
|
105
|
+
Accept: 'application/vnd.github+json',
|
|
106
|
+
'Content-Type': 'application/json',
|
|
107
|
+
'User-Agent': 'playwright-smart-test',
|
|
108
|
+
},
|
|
109
|
+
body: JSON.stringify({ body: markdown }),
|
|
110
|
+
});
|
|
111
|
+
if (updateRes.ok) {
|
|
112
|
+
console.log(pc.green(`✓ Updated Smart Regression comment on PR #${prNumber} in ${repo}`));
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
console.error(pc.red(`Failed to update PR comment: ${updateRes.status} ${updateRes.statusText}`));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
// Create new comment
|
|
121
|
+
const postRes = await fetch(`${apiUrl}/repos/${repo}/issues/${prNumber}/comments`, {
|
|
122
|
+
method: 'POST',
|
|
123
|
+
headers: {
|
|
124
|
+
Authorization: `Bearer ${token}`,
|
|
125
|
+
Accept: 'application/vnd.github+json',
|
|
126
|
+
'Content-Type': 'application/json',
|
|
127
|
+
'User-Agent': 'playwright-smart-test',
|
|
128
|
+
},
|
|
129
|
+
body: JSON.stringify({ body: markdown }),
|
|
130
|
+
});
|
|
131
|
+
if (postRes.ok) {
|
|
132
|
+
console.log(pc.green(`✓ Created Smart Regression comment on PR #${prNumber} in ${repo}`));
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
console.error(pc.red(`Failed to post PR comment: ${postRes.status} ${postRes.statusText}`));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
catch (err) {
|
|
141
|
+
console.error(pc.red(`Error posting GitHub PR comment: ${err instanceof Error ? err.message : String(err)}`));
|
|
142
|
+
}
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -52,7 +52,12 @@ export class GitHubReporter {
|
|
|
52
52
|
markdown += `\n`;
|
|
53
53
|
}
|
|
54
54
|
markdown += `### ⚡ Playwright Execution Command\n`;
|
|
55
|
-
|
|
55
|
+
if (result.selectedSpecs.length === 0 && !result.isFullRegression) {
|
|
56
|
+
markdown += `_No tests executed (0 impacted tests identified)._\n\n`;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
markdown += `\`\`\`bash\n${result.playwrightCommand}\n\`\`\`\n\n`;
|
|
60
|
+
}
|
|
56
61
|
markdown += `---\n*Generated automatically by Smart Regression Selection Agent*`;
|
|
57
62
|
return markdown;
|
|
58
63
|
}
|
|
@@ -51,7 +51,12 @@ export class TerminalReporter {
|
|
|
51
51
|
}
|
|
52
52
|
console.log(table.toString());
|
|
53
53
|
console.log(`\n${pc.bold('⚡ Playwright Execution Command:')}`);
|
|
54
|
-
|
|
54
|
+
if (result.selectedSpecs.length === 0 && !result.isFullRegression) {
|
|
55
|
+
console.log(` ${pc.gray('No tests required for this change (0 impacted tests identified).')}\n`);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
console.log(` ${pc.green(result.playwrightCommand)}\n`);
|
|
59
|
+
}
|
|
55
60
|
}
|
|
56
61
|
static formatRisk(score) {
|
|
57
62
|
switch (score) {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Socket Inc
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# @socketregistry/safe-buffer
|
|
2
|
+
|
|
3
|
+
[](https://socket.dev/npm/package/@socketregistry/safe-buffer)
|
|
4
|
+
[](https://github.com/SocketDev/socket-registry/actions/workflows/test.yml)
|
|
5
|
+
[](https://twitter.com/SocketSecurity)
|
|
6
|
+
|
|
7
|
+
> A tested zero dependency drop-in replacement of
|
|
8
|
+
> [`safe-buffer`](https://socket.dev/npm/package/safe-buffer) complete with
|
|
9
|
+
> TypeScript types.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
### Install as a package override
|
|
14
|
+
|
|
15
|
+
[`socket`](https://socket.dev/npm/package/socket) CLI will automagically ✨
|
|
16
|
+
populate
|
|
17
|
+
[overrides](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#overrides)
|
|
18
|
+
and [resolutions](https://yarnpkg.com/configuration/manifest#resolutions) of
|
|
19
|
+
your `package.json`.
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
npx socket optimize
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Prefer to do it yourself? Add `@socketregistry/safe-buffer` to your
|
|
26
|
+
`package.json`.
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"overrides": {
|
|
31
|
+
"safe-buffer": "npm:@socketregistry/safe-buffer@^1"
|
|
32
|
+
},
|
|
33
|
+
"resolutions": {
|
|
34
|
+
"safe-buffer": "npm:@socketregistry/safe-buffer@^1"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Install as a plain dependency
|
|
40
|
+
|
|
41
|
+
Install with your favorite package manager.
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
npm install @socketregistry/safe-buffer
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Requirements
|
|
48
|
+
|
|
49
|
+
Node >= `18.20.4`
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
// Use non-'node:' prefixed require to avoid Webpack errors.
|
|
4
|
+
// eslint-disable-next-line n/prefer-node-protocol
|
|
5
|
+
const { Buffer: UnsafeBuffer } = require('buffer')
|
|
6
|
+
|
|
7
|
+
const SafeBuffer = Object.defineProperties(function SafeBuffer(
|
|
8
|
+
arg,
|
|
9
|
+
encodingOrOffset,
|
|
10
|
+
length,
|
|
11
|
+
) {
|
|
12
|
+
return UnsafeBuffer.from(arg, encodingOrOffset, length)
|
|
13
|
+
}, Object.getOwnPropertyDescriptors(UnsafeBuffer))
|
|
14
|
+
|
|
15
|
+
module.exports = {
|
|
16
|
+
Buffer: SafeBuffer,
|
|
17
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@socketregistry/safe-buffer",
|
|
3
|
+
"version": "1.0.9",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Socket.dev optimized package override for safe-buffer",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"Socket.dev",
|
|
8
|
+
"package-overrides"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://github.com/SocketDev/socket-registry/tree/main/packages/npm/safe-buffer",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/SocketDev/socket-registry.git",
|
|
14
|
+
"directory": "packages/npm/safe-buffer"
|
|
15
|
+
},
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./index.d.ts",
|
|
19
|
+
"default": "./index.js"
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=18"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"*.d.ts",
|
|
29
|
+
"*.js"
|
|
30
|
+
],
|
|
31
|
+
"socket": {
|
|
32
|
+
"categories": [
|
|
33
|
+
"cleanup"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Socket Inc
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) Feross Aboukhadijeh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# @socketregistry/safe-buffer
|
|
2
|
+
|
|
3
|
+
[](https://socket.dev/npm/package/@socketregistry/safe-buffer)
|
|
4
|
+
[](https://github.com/SocketDev/socket-registry/actions/workflows/test.yml)
|
|
5
|
+
[](https://twitter.com/SocketSecurity)
|
|
6
|
+
|
|
7
|
+
> A tested zero dependency drop-in replacement of
|
|
8
|
+
> [`safe-buffer`](https://socket.dev/npm/package/safe-buffer) complete with
|
|
9
|
+
> TypeScript types.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
### Install as a package override
|
|
14
|
+
|
|
15
|
+
[`socket`](https://socket.dev/npm/package/socket) CLI will automagically ✨
|
|
16
|
+
populate
|
|
17
|
+
[overrides](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#overrides)
|
|
18
|
+
and [resolutions](https://yarnpkg.com/configuration/manifest#resolutions) of
|
|
19
|
+
your `package.json`.
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
npx socket optimize
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Prefer to do it yourself? Add `@socketregistry/safe-buffer` to your
|
|
26
|
+
`package.json`.
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"overrides": {
|
|
31
|
+
"safe-buffer": "npm:@socketregistry/safe-buffer@^1"
|
|
32
|
+
},
|
|
33
|
+
"resolutions": {
|
|
34
|
+
"safe-buffer": "npm:@socketregistry/safe-buffer@^1"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Install as a plain dependency
|
|
40
|
+
|
|
41
|
+
Install with your favorite package manager.
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
npm install @socketregistry/safe-buffer
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Requirements
|
|
48
|
+
|
|
49
|
+
Node >= `18.20.4`
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
// Use non-'node:' prefixed require to avoid Webpack errors.
|
|
4
|
+
// eslint-disable-next-line n/prefer-node-protocol
|
|
5
|
+
const { Buffer: UnsafeBuffer } = require('buffer')
|
|
6
|
+
|
|
7
|
+
const SafeBuffer = Object.defineProperties(function SafeBuffer(
|
|
8
|
+
arg,
|
|
9
|
+
encodingOrOffset,
|
|
10
|
+
length,
|
|
11
|
+
) {
|
|
12
|
+
return UnsafeBuffer.from(arg, encodingOrOffset, length)
|
|
13
|
+
}, Object.getOwnPropertyDescriptors(UnsafeBuffer))
|
|
14
|
+
|
|
15
|
+
module.exports = {
|
|
16
|
+
Buffer: SafeBuffer,
|
|
17
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@socketregistry/safe-buffer",
|
|
3
|
+
"version": "1.0.9",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Socket.dev optimized package override for safe-buffer",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"Socket.dev",
|
|
8
|
+
"package-overrides"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://github.com/SocketDev/socket-registry/tree/main/packages/npm/safe-buffer",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/SocketDev/socket-registry.git",
|
|
14
|
+
"directory": "packages/npm/safe-buffer"
|
|
15
|
+
},
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./index.d.ts",
|
|
19
|
+
"default": "./index.js"
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=18"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"*.d.ts",
|
|
29
|
+
"*.js"
|
|
30
|
+
],
|
|
31
|
+
"socket": {
|
|
32
|
+
"categories": [
|
|
33
|
+
"cleanup"
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Socket Inc
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) Feross Aboukhadijeh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|