Repositories

Connecting a repository, and linking a working directory to one.

4 sections3 min read

Most commands act on one repository. This page is how the CLI works out which one, and how to change its mind.

Connecting

Connectbash
cf repo connect
cf repo connect acme/api
cf repo connect --provider gitlab
cf repo connect acme/api --no-watch

With no argument, the repositories the connected account can reach are listed and you choose, as many as you like. With one, that repository is connected without a prompt. Either way the first scan is queued straight away, and followed unless you pass --no-watch.

All three hosts

--provider takes github, gitlab, or bitbucket. Leave it out and the CLI works out which host you mean: from the repository you named, from the single account you have connected, or from this directory's git remote. With more than one connected and nothing to go on, it asks.

The accounts themselvesbash
cf provider list
cf provider connect gitlab
cf provider disconnect bitbucket

cf provider list is one row per host with its state, the account it is connected as, and the server. cf provider disconnect disconnects a whole account after you type its login out, which stops every repository from that host being scanned.

Listing

What is connectedbash
cf repo list
cf status

cf repo list is the repositories and their scan state. cf status is the fuller picture: who you are signed in as, the provider connection, every repository with live scan progress and finding counts, and how many more are available to connect.

Linking a directory

The first time you run a repository-scoped command in a directory, the CLI asks which repository it corresponds to and remembers the answer, seeded from your git remote.

First run in a new directory
cf reproducedThis directory is not linked to a Cefense repository.  /Users/you/code/api  git remote  acme/apiHow should this directory resolve?> Link this directory to acme/api      matches your git remote  Link to a different repository  Just this once

Resolution order

  1. --repo owner/name on the command.
  2. The CEFENSE_REPO environment variable.
  3. The link stored for this directory.
  4. The prompt above, seeded from your git remote.

First match wins. --repo skips the question entirely, which is what to use in scripts. --no-link resolves without remembering, which is the non-interactive form of Just this once.

Setting the link ahead of timebash
cf repo set-default acme/api
cf repo set-default --unset

Disconnecting

Disconnectbash
cf repo disconnect acme/api
cf repo disconnect --account
cf repo disconnect --account --provider gitlab

The first stops one repository being scanned. The second disconnects a whole account, so no repository from it can be scanned until you connect it again; --provider says which host, and without it that means GitHub. Both ask you to type the name out first unless you pass --yes.

Have a correction or need help?

Email the docs team