Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(build): leave a bracketed host out of the gate's scp addresses
Yudhi Armyndharisa98af489bd14
diff --git a/scripts/check-dockerignore.mjs b/scripts/check-dockerignore.mjsindex 4ecb66823..a11ab508e 100644--- a/scripts/check-dockerignore.mjs+++ b/scripts/check-dockerignore.mjs@@ -179,9 +179,10 @@ const dockerfile = readFileSync(new URL('Dockerfile', root), 'utf8').join('\n').replace(/\\[ \t\r]*\n(?:[ \t\r]*\n)*/g, ' ');const wildcard = /[*?[]/;-// user@host:path as BuildKit takes it: a user of letters, digits, _ and -, and a host of letters, digits, . and --// or an IPv6 address in brackets.-const SCP_ADDRESS = /^[A-Za-z0-9_-]+@(?:[A-Za-z0-9.-]+|\[[0-9A-Fa-f:.]+\]):/;+// user@host:path as BuildKit takes it: a user of letters, digits, _ and -, and a host of letters, digits, . and -.+// A host in brackets is no scp address to it: [::1] is a class of characters, so the source is a pattern over+// the context.+const SCP_ADDRESS = /^[A-Za-z0-9_-]+@[A-Za-z0-9.-]+:/;function copyInputs(source) {// Remote, as BuildKit 0.34 reads it: an http(s) URL in lower case, a git:// or ssh:// URL in any case, or an// scp address user@host:path. Anything else, ftp://x/y, s3://x/y, file:///x, HTTPS://x/y or user@host, namesdiff --git a/scripts/check-dockerignore.spec.mjs b/scripts/check-dockerignore.spec.mjsindex a47effd3e..da822956f 100644--- a/scripts/check-dockerignore.spec.mjs+++ b/scripts/check-dockerignore.spec.mjs@@ -224,7 +224,6 @@ test('an http(s) URL in lower case, a git:// or ssh:// URL in any case and a use'[email protected]:org/repo.git','[email protected]:org/repo.git','[email protected]:org/repo.git',- 'deploy@[::1]:org/repo.git',];for (const source of remote) {const run = runGate({@@ -261,6 +260,17 @@ test('any other ADD source names a context path: ftp://, s3://, file:///, a sche}});+test('a bracketed host after user@ is a wildcard of the context to BuildKit, not an scp address', () => {+ // Real BuildKit 0.34 builds ADD deploy@[::1]:org/repo.git without a fetch: [::1] is a class of characters, so+ // the source is a pattern over the context, and one in a directory name is what this check cannot expand.+ const run = runGate({+ Dockerfile: 'COPY control.txt ./\nADD deploy@[::1]:org/repo.git /opt/\n',+ '.dockerignore': REAL_DOCKERIGNORE,+ });+ assert.equal(run.status, 1, run.out);+ assert.match(run.out, /expands a wildcard only in the file name/, run.out);+});+test('a wildcard in a directory name is reported instead of guessed', () => {const run = runGate({ Dockerfile: 'COPY su*/x.txt ./\n', '.dockerignore': REAL_DOCKERIGNORE });assert.equal(run.status, 1, run.out);