rigjs 4.0.17 → 4.0.18

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.
@@ -4,6 +4,7 @@ import crypto from 'crypto';
4
4
  import axios from 'axios';
5
5
  import * as uuid from 'uuid';
6
6
  import { DeployTarget } from '../CICD';
7
+ import { redactCdnUrl } from '@/utils/redact';
7
8
 
8
9
  type TFlag = 'break' | 'enhance_break' | null;
9
10
 
@@ -64,7 +65,7 @@ class CDN {
64
65
  });
65
66
 
66
67
  const url = `http://cdn.ap-southeast-1.aliyuncs.com?${paramConfig}`;
67
- console.log('cdn update url:', url);
68
+ console.log('cdn update url:', redactCdnUrl(url));
68
69
  const res = await axios.create().get(url);
69
70
  return res.data;
70
71
  }
@@ -3,6 +3,7 @@ import path from 'path';
3
3
  import CICD from '@/classes/cicd/CICD';
4
4
  import CICDCmd from '@/classes/cicd/CICDCmd';
5
5
  import AliOSS from '@/classes/cicd/Deploy/AliDeploy';
6
+ import { redactTarget } from '@/utils/redact';
6
7
 
7
8
  let filesList: string[] = [];
8
9
  const traverseFolder = (url: string) => {
@@ -33,7 +34,7 @@ export default async (cmd: any) => {
33
34
  const target = Array.isArray(cicdCmd.cicd.target)
34
35
  ? cicdCmd.cicd.target[0]
35
36
  : cicdCmd.cicd.target;
36
- console.log('oss tagert', target);
37
+ console.log('oss tagert', redactTarget(target));
37
38
  const aliOss = new AliOSS(target);
38
39
  console.log('Please Wait for Upload OSS...');
39
40
  if (!cicdCmd.endpoints || cicdCmd.endpoints.length === 0) {
@@ -0,0 +1,43 @@
1
+ import { maskSecret, redactTarget, redactCdnUrl } from '@/utils/redact';
2
+
3
+ test('maskSecret keeps a head+tail hint for long secrets', () => {
4
+ const ak = 'LTAI5t9GjXQc7itTohf68ZLq';
5
+ const masked = maskSecret(ak);
6
+ expect(masked).not.toContain('GjXQc7it'); // no middle bytes
7
+ expect(masked.startsWith('LTAI')).toBe(true);
8
+ expect(masked.endsWith('8ZLq')).toBe(true);
9
+ });
10
+
11
+ test('maskSecret returns plain mask for short / empty input', () => {
12
+ expect(maskSecret('')).toBe('');
13
+ expect(maskSecret(undefined)).toBe('');
14
+ expect(maskSecret('abc')).toBe('****');
15
+ expect(maskSecret('abcdefgh')).toBe('****');
16
+ });
17
+
18
+ test('redactTarget masks access_key / access_secret only', () => {
19
+ const out = redactTarget({
20
+ id: 'alicloud',
21
+ type: 'alicloud',
22
+ bucket: 'my-bucket',
23
+ region: 'oss-ap-southeast-1',
24
+ access_key: 'LTAI5t9GjXQc7itTohf68ZLq',
25
+ access_secret: '8jfykQQoK66RldfSo9YlfdLh423GXA',
26
+ root_path: '/',
27
+ });
28
+ expect(out.bucket).toBe('my-bucket');
29
+ expect(out.region).toBe('oss-ap-southeast-1');
30
+ expect(out.root_path).toBe('/');
31
+ expect(out.access_key).not.toContain('GjXQc7it');
32
+ expect(out.access_secret).not.toContain('QQoK66Rld');
33
+ });
34
+
35
+ test('redactCdnUrl masks AccessKeyId and Signature only', () => {
36
+ const url =
37
+ 'http://cdn.ap-southeast-1.aliyuncs.com?AccessKeyId=LTAI5t9GjXQc7itTohf68ZLq&Action=BatchSetCdnDomainConfig&Signature=iUppVaZSIecVi3DhZZeBCf24Ag0%3D&Timestamp=2026-05-25T08%3A40%3A51.135Z';
38
+ const masked = redactCdnUrl(url);
39
+ expect(masked).not.toContain('LTAI5t9GjXQc7itTohf68ZLq');
40
+ expect(masked).not.toContain('iUppVaZSIecVi3DhZZeBCf24Ag0');
41
+ expect(masked).toContain('Action=BatchSetCdnDomainConfig');
42
+ expect(masked).toContain('Timestamp=2026-05-25');
43
+ });
@@ -0,0 +1,48 @@
1
+ // Helpers to keep cloud credentials out of stdout.
2
+ //
3
+ // rig's deploy/publish flow prints (a) the resolved deploy target and
4
+ // (b) every Aliyun CDN API URL. Both carry the AccessKeyId / AccessKeySecret
5
+ // in clear, which makes the console output unsafe to copy/paste into issues,
6
+ // CI logs, or chat.
7
+ //
8
+ // Use `maskSecret` for short identifiers (keeps a head+tail hint so two
9
+ // different keys are still distinguishable in logs), `redactTarget` before
10
+ // console-logging a DeployTarget, and `redactCdnUrl` before logging any
11
+ // signed Aliyun OpenAPI URL.
12
+
13
+ /** Mask a credential while keeping a short prefix + suffix for debuggability. */
14
+ export function maskSecret(s: string | undefined | null): string {
15
+ if (!s) return '';
16
+ if (s.length <= 8) return '****';
17
+ return `${s.slice(0, 4)}…${s.slice(-4)}`;
18
+ }
19
+
20
+ /**
21
+ * Return a shallow copy of a DeployTarget-shaped object with `access_key`
22
+ * and `access_secret` masked. Unknown keys pass through unchanged.
23
+ */
24
+ export function redactTarget<T extends Record<string, any>>(target: T): T {
25
+ if (!target || typeof target !== 'object') return target;
26
+ const out: Record<string, any> = { ...target };
27
+ if (typeof out.access_key === 'string') out.access_key = maskSecret(out.access_key);
28
+ if (typeof out.access_secret === 'string') out.access_secret = maskSecret(out.access_secret);
29
+ return out as T;
30
+ }
31
+
32
+ /**
33
+ * Redact `AccessKeyId` and `Signature` query parameters from an Aliyun
34
+ * OpenAPI URL so the URL can be safely logged. Leaves all other params
35
+ * (Action, Timestamp, etc.) intact for debugging.
36
+ */
37
+ export function redactCdnUrl(url: string): string {
38
+ if (!url) return url;
39
+ return url
40
+ .replace(/([?&]AccessKeyId=)([^&]+)/i, (_m, p1, v) => `${p1}${maskSecret(v)}`)
41
+ .replace(/([?&]Signature=)([^&]+)/i, (_m, p1) => `${p1}REDACTED`);
42
+ }
43
+
44
+ export default {
45
+ maskSecret,
46
+ redactTarget,
47
+ redactCdnUrl,
48
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rigjs",
3
- "version": "4.0.17",
4
- "versionCode": 26052424,
3
+ "version": "4.0.18",
4
+ "versionCode": 26052501,
5
5
  "description": "A multi-repos dev tool based on yarn and git.Rigjs is intended to be the simplest way to develop,share and deliver codes between different developers or different projects.",
6
6
  "keywords": [
7
7
  "modular",