@effected/github-actions 0.28.2 → 0.29.1

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/ActionCache.js CHANGED
@@ -2,6 +2,7 @@ import { ActionEnvironment } from "./ActionEnvironment.js";
2
2
  import { unstubbed } from "./internal/unstubbed.js";
3
3
  import { BlobTransferError } from "./BlobTransfer.js";
4
4
  import { misconfiguredDetail, resultsBackend } from "./internal/actionsResults.js";
5
+ import { blobCause } from "./internal/blobCause.js";
5
6
  import { twirpCall, twirpFailureFields } from "./internal/twirp.js";
6
7
  import { CACHE_SERVICE, finalizeUpload, lookupDownload, reserveUpload } from "./internal/cacheService.js";
7
8
  import { sha256Hex } from "./internal/digest.js";
@@ -100,14 +101,14 @@ const azure = {
100
101
  }),
101
102
  catch: (cause) => new BlobTransferError({
102
103
  reason: "uploadFailed",
103
- cause
104
+ cause: blobCause(cause)
104
105
  })
105
106
  }).pipe(Effect.asVoid),
106
107
  downloadToFile: (url, file) => Effect.tryPromise({
107
108
  try: () => new BlobClient(url).downloadToFile(file),
108
109
  catch: (cause) => new BlobTransferError({
109
110
  reason: "downloadFailed",
110
- cause
111
+ cause: blobCause(cause)
111
112
  })
112
113
  }).pipe(Effect.asVoid)
113
114
  };
package/Artifact.js CHANGED
@@ -2,6 +2,7 @@ import { ActionEnvironment } from "./ActionEnvironment.js";
2
2
  import { unstubbed } from "./internal/unstubbed.js";
3
3
  import { BlobTransferError } from "./BlobTransfer.js";
4
4
  import { misconfiguredDetail, resultsBackend } from "./internal/actionsResults.js";
5
+ import { blobCause } from "./internal/blobCause.js";
5
6
  import { CONFLICT, field, isOk, stringField, twirpCall, twirpFailureFields } from "./internal/twirp.js";
6
7
  import { digestFileHex } from "./internal/digest.js";
7
8
  import { isWindowsRunner } from "./internal/runner.js";
@@ -94,14 +95,14 @@ const azure = {
94
95
  }),
95
96
  catch: (cause) => new BlobTransferError({
96
97
  reason: "uploadFailed",
97
- cause
98
+ cause: blobCause(cause)
98
99
  })
99
100
  }).pipe(Effect.asVoid),
100
101
  downloadToFile: (url, file) => Effect.tryPromise({
101
102
  try: () => new BlobClient(url).downloadToFile(file),
102
103
  catch: (cause) => new BlobTransferError({
103
104
  reason: "downloadFailed",
104
- cause
105
+ cause: blobCause(cause)
105
106
  })
106
107
  }).pipe(Effect.asVoid)
107
108
  };
@@ -1,6 +1,7 @@
1
1
  import { ActionEnvironment } from "./ActionEnvironment.js";
2
2
  import { BlobTransferError } from "./BlobTransfer.js";
3
3
  import { misconfiguredDetail, resultsBackend } from "./internal/actionsResults.js";
4
+ import { blobCause } from "./internal/blobCause.js";
4
5
  import { twirpCall, twirpFailureFields } from "./internal/twirp.js";
5
6
  import { CACHE_SERVICE, finalizeUpload, lookupDownload, reserveUpload } from "./internal/cacheService.js";
6
7
  import { sha256Hex } from "./internal/digest.js";
@@ -40,14 +41,14 @@ const azure = {
40
41
  try: () => new BlockBlobClient(url).uploadData(data),
41
42
  catch: (cause) => new BlobTransferError({
42
43
  reason: "uploadFailed",
43
- cause
44
+ cause: blobCause(cause)
44
45
  })
45
46
  }).pipe(Effect.asVoid),
46
47
  downloadToBuffer: (url) => Effect.tryPromise({
47
48
  try: () => new BlobClient(url).downloadToBuffer(),
48
49
  catch: (cause) => new BlobTransferError({
49
50
  reason: "downloadFailed",
50
- cause
51
+ cause: blobCause(cause)
51
52
  })
52
53
  }).pipe(Effect.map((buffer) => new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength)))
53
54
  };
package/BlobStore.js CHANGED
@@ -3,7 +3,7 @@ import { Secret } from "./Secret.js";
3
3
  import { BlobEnvelope } from "./BlobEnvelope.js";
4
4
  import { Context, Crypto, DateTime, Effect, Layer, Option, Schema } from "effect";
5
5
  import { HttpClient, HttpClientRequest } from "effect/http";
6
- import { SigV4 } from "@effected/crypto";
6
+ import { HttpRedaction, SigV4 } from "@effected/crypto";
7
7
 
8
8
  // src/BlobStore.ts
9
9
  /**
@@ -188,7 +188,7 @@ const makeS3 = (config) => Effect.gen(function* () {
188
188
  return yield* http.execute(built).pipe(Effect.mapError((cause) => new BlobStoreError({
189
189
  reason: "unreachable",
190
190
  key,
191
- cause
191
+ cause: HttpRedaction.cause(cause)
192
192
  })));
193
193
  });
194
194
  /** Anything outside 2xx is the store refusing; a caller reads `404` first where a miss is an answer. */
@@ -205,7 +205,7 @@ const makeS3 = (config) => Effect.gen(function* () {
205
205
  const buffer = yield* response.arrayBuffer.pipe(Effect.mapError((cause) => new BlobStoreError({
206
206
  reason: "unreachable",
207
207
  key,
208
- cause
208
+ cause: HttpRedaction.cause(cause)
209
209
  })));
210
210
  return Option.some(yield* Effect.fromResult(BlobEnvelope.decodeResult(new Uint8Array(buffer), schema)));
211
211
  }),
package/CacheKey.js CHANGED
@@ -375,7 +375,7 @@ var CacheKey = class CacheKey extends Schema.Class("CacheKey")(Schema.Struct({
375
375
  static matchingFiles = Effect.fn("CacheKey.matchingFiles")(function* (options) {
376
376
  const fs = yield* FileSystem.FileSystem;
377
377
  const path = yield* Path.Path;
378
- const { workspace } = options;
378
+ const workspace = path.resolve(options.workspace);
379
379
  const set = yield* GlobSet.compile(options.patterns).pipe(Effect.mapError((cause) => new CacheKeyBadPatternError({
380
380
  pattern: cause.pattern,
381
381
  cause
@@ -4,6 +4,7 @@ import { ActionOutputs } from "./ActionOutputs.js";
4
4
  import { Secret } from "./Secret.js";
5
5
  import { Context, Effect, Layer, Redacted, Schema } from "effect";
6
6
  import { HttpClient, HttpClientRequest } from "effect/http";
7
+ import { HttpRedaction } from "@effected/crypto";
7
8
  import { Oidc } from "@effected/oidc";
8
9
  import { ActionsOidcClaimsFromWire } from "@effected/github";
9
10
  import * as Base64Url from "effect/encoding/Base64Url";
@@ -109,7 +110,7 @@ const make = Effect.gen(function* () {
109
110
  const url = audience === void 0 ? base : `${base}&audience=${encodeURIComponent(audience)}`;
110
111
  const response = yield* http.execute(HttpClientRequest.get(url).pipe(HttpClientRequest.bearerToken(bearer), HttpClientRequest.acceptJson)).pipe(Effect.mapError((cause) => new OidcTokenError({
111
112
  reason: "requestFailed",
112
- cause
113
+ cause: HttpRedaction.cause(cause)
113
114
  })));
114
115
  if (response.status < 200 || response.status >= 300) return yield* Effect.fail(new OidcTokenError({
115
116
  reason: "requestFailed",
@@ -117,7 +118,7 @@ const make = Effect.gen(function* () {
117
118
  }));
118
119
  const envelope = yield* HttpClientResponse.schemaBodyJson(TokenEnvelope)(response).pipe(Effect.mapError((cause) => new OidcTokenError({
119
120
  reason: "malformedResponse",
120
- cause
121
+ cause: HttpRedaction.cause(cause)
121
122
  })));
122
123
  yield* Secret.mask(Redacted.make(envelope.value)).pipe(Effect.provideService(ActionOutputs, outputs));
123
124
  return envelope.value;
package/ToolInstaller.js CHANGED
@@ -7,6 +7,7 @@ import { isErrno, typeAt } from "./internal/fsProbe.js";
7
7
  import { Context, Effect, FileSystem, Layer, Option, Path, Schedule, Schema, Stream } from "effect";
8
8
  import { HttpClient } from "effect/http";
9
9
  import { ChildProcessSpawner } from "effect/process";
10
+ import { HttpRedaction } from "@effected/crypto";
10
11
 
11
12
  // src/ToolInstaller.ts
12
13
  /**
@@ -27,7 +28,7 @@ var ToolInstallerError = class extends Schema.TaggedError()("ToolInstallerError"
27
28
  ]),
28
29
  /** The HTTP status, when there was one. Drives the retry decision. */
29
30
  status: Schema.optionalKey(Schema.Number),
30
- /** What was being worked on — a url, an archive path, or a tool name. */
31
+ /** What was being worked on — a url (with userinfo and credential query values redacted), an archive path, or a tool name. */
31
32
  subject: Schema.String,
32
33
  /** The extraction tool's own complaint, which is the only useful part of a tar failure. */
33
34
  stderr: Schema.optionalKey(Schema.String),
@@ -176,32 +177,33 @@ const make = Effect.gen(function* () {
176
177
  force: true
177
178
  }))))));
178
179
  const download = Effect.fn("ToolInstaller.download")(function* (url, options) {
180
+ const subject = HttpRedaction.url(url);
179
181
  return yield* Effect.gen(function* () {
180
182
  const response = yield* http.get(url).pipe(Effect.mapError((cause) => new ToolInstallerError({
181
183
  reason: "downloadFailed",
182
- subject: url,
183
- cause
184
+ subject,
185
+ cause: HttpRedaction.cause(cause)
184
186
  })));
185
187
  if (response.status < 200 || response.status >= 300) return yield* Effect.fail(new ToolInstallerError({
186
188
  reason: "downloadFailed",
187
- subject: url,
189
+ subject,
188
190
  status: response.status
189
191
  }));
190
192
  const directory = yield* fs.makeTempDirectory({ prefix: "effected-download-" }).pipe(Effect.mapError((cause) => new ToolInstallerError({
191
193
  reason: "downloadFailed",
192
- subject: url,
194
+ subject,
193
195
  cause
194
196
  })));
195
197
  const file = path.join(directory, "download");
196
198
  yield* Stream.run(response.stream, fs.sink(file)).pipe(Effect.mapError((cause) => new ToolInstallerError({
197
199
  reason: "downloadFailed",
198
- subject: url,
199
- cause
200
+ subject,
201
+ cause: HttpRedaction.cause(cause)
200
202
  })));
201
203
  return file;
202
204
  }).pipe(Effect.timeout(options?.timeout ?? DOWNLOAD_TIMEOUT), Effect.catchTag("TimeoutError", (cause) => Effect.fail(new ToolInstallerError({
203
205
  reason: "downloadFailed",
204
- subject: url,
206
+ subject,
205
207
  cause
206
208
  }))), Effect.retry({
207
209
  schedule: Schedule.exponential("1 second"),
package/index.d.ts CHANGED
@@ -1418,7 +1418,11 @@ export declare class CacheKey extends CacheKey_base {
1418
1418
  * the filesystem happened to report.
1419
1419
  */
1420
1420
  static readonly matchingFiles: (options: {
1421
- /** The directory to walk. Nothing outside it is ever considered. */
1421
+ /**
1422
+ * The directory to walk. Nothing outside it is ever considered. A
1423
+ * relative workspace (`"."`, `"packages/app"`) resolves against the
1424
+ * process working directory, and the answer is absolute either way.
1425
+ */
1422
1426
  readonly workspace: string;
1423
1427
  /** Include patterns, with a leading `!` marking an exclusion. */
1424
1428
  readonly patterns: ReadonlyArray<string>;
@@ -1451,6 +1455,7 @@ export declare class CacheKey extends CacheKey_base {
1451
1455
  * ```
1452
1456
  */
1453
1457
  static readonly hashMatching: (options: {
1458
+ /** The directory to walk; a relative one resolves against the process working directory. */
1454
1459
  readonly workspace: string;
1455
1460
  readonly patterns: ReadonlyArray<string>;
1456
1461
  }) => Effect.Effect<Option.Option<string>, CacheKeyBadPatternError | CacheKeyReadError, FileSystem.FileSystem | Path.Path>;
@@ -4958,7 +4963,7 @@ declare const ToolInstallerError_base: Schema.Class<ToolInstallerError, Schema.T
4958
4963
  readonly reason: Schema.Literals<readonly ["downloadFailed", "extractFailed", "cacheFailed"]>;
4959
4964
  /** The HTTP status, when there was one. Drives the retry decision. */
4960
4965
  readonly status: Schema.optionalKey<Schema.Number>;
4961
- /** What was being worked on — a url, an archive path, or a tool name. */
4966
+ /** What was being worked on — a url (with userinfo and credential query values redacted), an archive path, or a tool name. */
4962
4967
  readonly subject: Schema.String;
4963
4968
  /** The extraction tool's own complaint, which is the only useful part of a tar failure. */
4964
4969
  readonly stderr: Schema.optionalKey<Schema.String>;
@@ -0,0 +1,100 @@
1
+ import { Predicate } from "effect";
2
+ import { UrlParams } from "effect/http";
3
+ import { HttpRedaction } from "@effected/crypto";
4
+
5
+ // src/internal/blobCause.ts
6
+ const REDACTED = "REDACTED";
7
+ const SAS_NAMES = [
8
+ "sig",
9
+ "se",
10
+ "st",
11
+ "sp",
12
+ "sip",
13
+ "skoid",
14
+ "sktid",
15
+ "skt",
16
+ "ske",
17
+ "saoid",
18
+ "suoid",
19
+ "scid"
20
+ ];
21
+ /** A signed blob url with its SAS credential fields and userinfo redacted. */
22
+ const blobUrl = (raw) => UrlParams.redactUrl(HttpRedaction.url(raw), SAS_NAMES);
23
+ const text = (raw) => HttpRedaction.text(raw).replace(/https?:\/\/[^\s"'<>`]+/gi, (match) => UrlParams.redactUrl(match, SAS_NAMES));
24
+ /** A header record (`details`, or a response's headers) minus cookies, sensitive values redacted. */
25
+ const headerRecord = (input) => {
26
+ const entries = headerEntries(input);
27
+ if (entries === void 0) return void 0;
28
+ const out = {};
29
+ for (const [name, value] of entries) {
30
+ const lower = name.toLowerCase();
31
+ if (lower === "set-cookie" || lower === "cookie") continue;
32
+ if (typeof value === "string") out[name] = HttpRedaction.isSensitiveHeader(lower) ? REDACTED : text(value);
33
+ else if (Predicate.isNumber(value) || Predicate.isBoolean(value)) out[name] = value;
34
+ }
35
+ return out;
36
+ };
37
+ const headerEntries = (input) => {
38
+ if (input === null || typeof input !== "object") return void 0;
39
+ if (Predicate.hasProperty(input, "toJSON") && typeof input.toJSON === "function") {
40
+ const json = input.toJSON();
41
+ return json !== null && typeof json === "object" ? Object.entries(json) : void 0;
42
+ }
43
+ return Object.entries(input);
44
+ };
45
+ const isRestShaped = (value) => Predicate.hasProperty(value, "request") || Predicate.hasProperty(value, "response");
46
+ const MAX_DEPTH = 8;
47
+ const define = (target, key, value, enumerable) => {
48
+ Object.defineProperty(target, key, {
49
+ value,
50
+ enumerable,
51
+ writable: true,
52
+ configurable: true
53
+ });
54
+ };
55
+ const copy = (value, depth) => {
56
+ if (typeof value === "string") return text(value);
57
+ if (value === null || typeof value !== "object") return value;
58
+ if (depth >= MAX_DEPTH) return void 0;
59
+ const source = value;
60
+ const out = value instanceof Error ? Object.create(Object.getPrototypeOf(value)) : new Error(text(typeof source.message === "string" ? source.message : Object.prototype.toString.call(value)));
61
+ if (value instanceof Error) {
62
+ define(out, "message", text(value.message), false);
63
+ if (value.stack !== void 0) define(out, "stack", text(value.stack), false);
64
+ }
65
+ for (const [key, field] of Object.entries(source)) if (key === "details") {
66
+ const details = headerRecord(field);
67
+ if (details !== void 0) define(out, key, details, true);
68
+ } else if (typeof field === "string") define(out, key, text(field), true);
69
+ else if (Predicate.isNumber(field) || Predicate.isBoolean(field)) define(out, key, field, true);
70
+ const request = Predicate.hasProperty(value, "request") ? asRecord(value.request) : void 0;
71
+ if (request !== void 0) define(out, "request", {
72
+ ...typeof request.method === "string" ? { method: request.method } : {},
73
+ ...typeof request.url === "string" ? { url: blobUrl(request.url) } : {},
74
+ ...headerRecord(request.headers) !== void 0 ? { headers: headerRecord(request.headers) } : {}
75
+ }, false);
76
+ const response = Predicate.hasProperty(value, "response") ? asRecord(value.response) : void 0;
77
+ if (response !== void 0) define(out, "response", {
78
+ ...Predicate.isNumber(response.status) ? { status: response.status } : {},
79
+ ...headerRecord(response.headers) !== void 0 ? { headers: headerRecord(response.headers) } : {}
80
+ }, false);
81
+ if (Predicate.hasProperty(value, "cause") && value.cause !== void 0) {
82
+ const nested = copy(value.cause, depth + 1);
83
+ if (nested !== void 0) define(out, "cause", nested, true);
84
+ }
85
+ return out;
86
+ };
87
+ const asRecord = (value) => value !== null && typeof value === "object" ? value : void 0;
88
+ /**
89
+ * Sanitize what a blob transfer threw before keeping it as a cause: a
90
+ * `RestError`-shaped value (one carrying a `request` or `response`) becomes a
91
+ * copy on the same prototype that keeps `name`, `message`, `code`,
92
+ * `statusCode`, the method, the url with its SAS credential fields redacted,
93
+ * and the headers minus `set-cookie`, with sensitive values redacted; the
94
+ * request and response bodies, the pipeline options and the raw url are gone.
95
+ * Anything else — a filesystem error writing the download, a kit error — is
96
+ * returned unchanged, by identity.
97
+ */
98
+ const blobCause = (cause) => cause !== null && typeof cause === "object" && isRestShaped(cause) ? copy(cause, 0) : cause;
99
+
100
+ export { blobCause, blobUrl };
package/internal/twirp.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Effect, Schedule } from "effect";
2
2
  import { HttpClientRequest } from "effect/http";
3
+ import { HttpRedaction } from "@effected/crypto";
3
4
 
4
5
  // src/internal/twirp.ts
5
6
  /**
@@ -65,7 +66,7 @@ const twirpCall = (options) => {
65
66
  const response = yield* http.execute(request).pipe(Effect.mapError((cause) => ({
66
67
  method,
67
68
  kind: "transport",
68
- cause
69
+ cause: HttpRedaction.cause(cause)
69
70
  })));
70
71
  if (response.status === 409) return CONFLICT;
71
72
  if (response.status < 200 || response.status >= 300) return yield* Effect.fail({
@@ -76,7 +77,7 @@ const twirpCall = (options) => {
76
77
  return yield* response.json.pipe(Effect.mapError((cause) => ({
77
78
  method,
78
79
  kind: "malformed",
79
- cause
80
+ cause: HttpRedaction.cause(cause)
80
81
  })));
81
82
  }).pipe(Effect.retry({
82
83
  schedule: Schedule.exponential("3 seconds", 1.5),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effected/github-actions",
3
- "version": "0.28.2",
3
+ "version": "0.29.1",
4
4
  "private": false,
5
5
  "description": "The GitHub Actions runtime: env, inputs, outputs, state, logging, cache, artifacts, blob storage, OIDC and the token bridge.",
6
6
  "keywords": [
@@ -39,19 +39,19 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@azure/storage-blob": "^12.33.0",
42
- "@effected/crypto": "^0.2.1",
43
- "@effected/github": "^0.25.1",
44
- "@effected/github-commands": "^0.6.2",
45
- "@effected/glob": "^0.15.0",
46
- "@effected/jwt": "^0.6.0",
47
- "@effected/markdown": "^0.23.0",
48
- "@effected/npm": "^0.27.1",
49
- "@effected/oidc": "^0.1.2",
50
- "@effected/sbom": "^0.17.0",
51
- "@effected/semver": "^0.18.0",
52
- "@effected/templates": "^0.14.1",
53
- "@effected/walker": "^0.21.0",
54
- "@effected/yaml": "^0.25.1"
42
+ "@effected/crypto": "^0.3.0",
43
+ "@effected/github": "^0.26.0",
44
+ "@effected/github-commands": "^0.7.0",
45
+ "@effected/glob": "^0.16.0",
46
+ "@effected/jwt": "^0.7.0",
47
+ "@effected/markdown": "^0.24.0",
48
+ "@effected/npm": "^0.28.0",
49
+ "@effected/oidc": "^0.2.0",
50
+ "@effected/sbom": "^0.18.0",
51
+ "@effected/semver": "^0.19.0",
52
+ "@effected/templates": "^0.15.0",
53
+ "@effected/walker": "^0.23.0",
54
+ "@effected/yaml": "^0.26.0"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "@effect/platform-node": "^4.0.0",
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.59.4"
8
+ "packageVersion": "7.60.0"
9
9
  }
10
10
  ]
11
11
  }