Line

ui/server/src/gitUrl

slice A -- what a "clone this repository" request is allowed to name.

Cockpit server, v0.9. Source: ui/server/src/gitUrl.mjs.

Classes#

CloneInputError#

Defined in: ui/server/src/gitUrl.mjs:15

Extends#

  • Error

Constructors#

Constructor

new CloneInputError(code, message, status?): CloneInputError

Defined in: ui/server/src/gitUrl.mjs:17

Parameters
code

string

message

string

status?

number = 400

Returns

CloneInputError

Overrides

Error.constructor

Properties#

code

code: string

Defined in: ui/server/src/gitUrl.mjs:20

name

name: string

Defined in: ui/server/src/gitUrl.mjs:19

Inherited from

Error.name

status

status: number

Defined in: ui/server/src/gitUrl.mjs:21

Variables#

DEFAULT_CLONE_HOSTS#

const DEFAULT_CLONE_HOSTS: readonly string[]

Defined in: ui/server/src/gitUrl.mjs:11

Hosts a clone may name when nothing is configured. gitlab.com / bitbucket.org are opt-in.


MAX_SLUG_LENGTH#

const MAX_SLUG_LENGTH: 100 = 100

Defined in: ui/server/src/gitUrl.mjs:13


MAX_URL_LENGTH#

const MAX_URL_LENGTH: 300 = 300

Defined in: ui/server/src/gitUrl.mjs:12

Functions#

isPublicAddress()#

isPublicAddress(addr): boolean

Defined in: packages/engine/safeFetch.mjs:46

Is addr (an IP literal) an address on the public internet? Loopback, private, link-local, CGNAT, multicast, unspecified, documentation, benchmarking and reserved ranges are not. Anything that is not an IP literal is not.

Parameters#

addr

string

Returns#

boolean


parseCloneUrl()#

parseCloneUrl(input, opts?): object

Defined in: ui/server/src/gitUrl.mjs:68

Parameters#

input

unknown

what the client sent

opts?

localRoot (test harness only): also accept a file:// URL naming an absolute path under that directory.

hosts?

readonly string[] = DEFAULT_CLONE_HOSTS

localRoot?

string = null

Returns#

object

display

display: string

host

host: string

kind

kind: "https" | "file"

owner

owner: string

repo

repo: string

slug

slug: string

url

url: string


resolveCloneHosts()#

resolveCloneHosts(env?): any

Defined in: ui/server/src/gitUrl.mjs:30

The configured host allowlist: CONSTRUCT_CLONE_HOSTS=github.com,gitlab.com (lowercase hostnames only; anything that is not a plain hostname is dropped, so a typo cannot widen the list).

Parameters#

env?

any = process.env

Returns#

any


validateBranch()#

validateBranch(branch): string

Defined in: ui/server/src/gitUrl.mjs:53

#330: a branch (or tag) name to check out. A closed set, stricter than the version-control tool's own rules: letters, digits and . _ - / inside, starting with a letter or digit (so it can never look like an option), no .., //, no trailing / . or .lock. -> the name, or null when none was given.

Parameters#

branch

any

Returns#

string


validateSlug()#

validateSlug(slug): string

Defined in: ui/server/src/gitUrl.mjs:41

A destination folder name (also the repo name): plain ASCII, starts alphanumeric, no .., no trailing dot.

Parameters#

slug

any

Returns#

string