DevSecOps CLI
DevSecOps CLI adotta soluzioni di conformità nell'ambito dell'implementazione di riferimento di IBM Cloud® DevSecOps; ad esempio, le pipeline di riferimento con approccio shift-left. Per ulteriori informazioni sull'architettura di conformità shift-left, consultare DevSecOps con Continuous Delivery.
Interfaccia CLI
La CLI usa una struttura multipart sulla riga di comando che devi specificare nel seguente ordine:
cocoa <command> <subcommand> [options]
-
La chiamata di base alla CLI.
-
Il comando principale, che di solito corrisponde a un servizio o a un modulo utilizzato dall'architettura shift - left; ad esempio, richiesta di modifica, inventario o tekton.
-
Il sottocomando che specifica quale azione eseguire.
-
Opzioni CLI richieste dall'azione. A condizione che seguano i passi da 1 a 3, puoi specificare le opzioni CLI in qualsiasi ordine.
Alcuni comandi utilizzano le variabili di ambiente per ottenere le chiavi API o per configurare un valore di opzione che non è stato fornito nella riga comandi. È necessario esportare queste variabili prima di eseguire il comando.
Le opzioni della riga comandi possono assumere vari tipi di valori di input, come numeri, stringhe, valori booleani, array e oggetti JSON. Il tipo di opzioni dipende dal comando specificato. Utilizzare cocoa <command> <subcommand> --help per visualizzare i tipi di opzioni.
Nuovo tentativo di chiamate API non riuscite
La CLI Cacao riprova tutte le chiamate API che hanno esito negativo con uno stato di risposta di 5xx tre volte. È possibile sovrascrivere questo comportamento fornendo le seguenti variabili di ambiente:
MAX_RETRY_ATTEMPTS- Il numero di tentativi effettuati dalla CLI Cocoa prima che venga annullata. Ad esempio,MAX_RETRY_ATTEMPTS=5RETRY_STATUS_CODE- I codici di stato della risposta per cui si verifica un nuovo tentativo. Ad esempio,RETRY_STATUS_CODE=409,422,500per riprovare con questi tre codici di stato.
export MAX_RETRY_ATTEMPTS=5 # Retry API calls 5 times.
export RETRY_STATUS_CODE=409,422,500 # Retry API calls for response codes 409, 422 and 500.
I tentativi sono distanziati esponenzialmente nel tempo, quindi l'impostazione di tentativi più elevati fa sì che i tentativi siano distanziati ulteriormente.
Tempo trascorso per l'esecuzione del comando
La CLI di Cocoa può visualizzare il tempo trascorso di qualsiasi comando in secondi impostando DISPLAY_ELAPSED_TIME su una stringa non vuota come segue:
export DISPLAY_ELAPSED_TIME=1` # Display a snippet showing the total execution time of the cli command, example `Elapsed time: 5.32 seconds`
Comandi della CLI
Sebbene ServiceNow sia documentato, non è supportato dall'implementazione di riferimento predefinita IBM Cloud DevSecOps.
comandi di richiesta di estrazione cacao
Controllo del cacao - richiesta - approvazione
Controlla lo stato di approvazione di una richiesta di pull su un hash di commit. Se la richiesta di pull non è stata approvata, crea un nuovo problema di incidente nel repository specificato. Il comando può identificare le richieste di pull
di emergenza contrassegnate con un'etichetta, in questo caso ha il codice di uscita 0.
Variabili di ambiente richieste:
GHE_TOKEN= # Github Enterprise API Token (Optional if you are using --git-token-path field)
GHE_ORG= # The owner of the repository
GHE_REPO= # The repository name
INCIDENT_ISSUE_REPO= # The incident issue repo name
EMERGENCY_LABEL= # Emergency Label name
GIT_COMMIT= # Commit hash of the Pull Request
Opzioni:
--label # Label to add to possible pr incident issue
--git-provider # SCM provider (GitHub)
--git-token-path # (Optional) GitHub Token's path
--git-api-url # (Optional) GitHub API url
Se si usa GitHub, si può usare il campo --git-token-path per impostare il token GitHub e il campo --git-api-url per impostare l' URL dell'API GitHub Enterprise, invece delle variabili d'ambiente GHE_TOKEN e GH_URL. Se vengono fornite entrambe, --git-token-path e --git-api-url hanno la precedenza.
Esecuzione del comando:
cocoa check pull-request-approval
Cacao check pull - request - status
Verifica lo stato di una determinata richiesta pull e le impostazioni dei repository.
- Protezione ramo: regole per disabilitare l'inserimento forzato, impedire l'eliminazione dei rami e, facoltativamente, richiedere i controlli di stato prima dell'unione. Come miglioramento, oltre alla tradizionale convalida basata su Branch Protection, il comando supporta anche la convalida basata su Ruleset per i repository GitHub. Per impostazione predefinita, il comando verifica la presenza di un set di regole associato al ramo nel repository GitHub e, se non viene trovato alcun set di regole, ricorre alla convalida tradizionale basata sulla protezione del ramo. Se per un ramo sono presenti sia la regola di protezione Ruleset che quella tradizionale, il comando prende in considerazione solo Ruleset. Per ulteriori informazioni sui set di regole di GitHub, vedere Configurazione del repository GitHub
- Controllo stato commit: i servizi esterni per contrassegnare i commit con uno stato
error,failure,pendingosuccess, che si riflette nelle richieste di pull che coinvolgono tali commit. - Controlla esecuzioni: applicazioni che eseguono servizi di integrazione continua, di collegamento del codice o di scansione del codice e forniscono un feedback dettagliato sui commit.
Variabili di ambiente richieste:
REQUIRED_CHECKS= # Minimum required checks to be compliant set by client
GIT_BRANCH= # Branch name for branch protection check
GIT_COMMIT= # Commit hash of the Pull Request
GHE_TOKEN= # Github Enterprise API Token (Optional if you are using --git-token-path field)
GHE_ORG= # The owner of the repository
GHE_REPO= # The repository name
Se si usa GitHub, si può usare il campo --git-token-path per impostare il token GitHub e il campo --git-api-url per impostare l' URL dell'API GitHub Enterprise, invece delle variabili d'ambiente GHE_TOKEN e GH_URL. Se vengono fornite entrambe le coppie GHE_TOKEN GH_URL e --git-token-path --git-api-url, --git-token-path e --git-api-url hanno la precedenza.
Per specificare il percorso del file di output per le impostazioni di Branch Protection, utilizzare l'opzione '--branch-protection-settings-output-path. Quando il ramo è protetto, la rappresentazione JSON delle impostazioni
di protezione del ramo del repository sarà salvata in questo percorso specificato.
Per specificare il percorso del file di output per il 'Risultati della convalida di Branch Protection, utilizzare l'opzione '--branch-protection-markdown-output-path. Quando il ramo è protetto, i risultati della convalida
saranno salvati in formato Markdown nel percorso specificato.
REQUIRED_CHECKS Esempio:
[
{
"type": "status",
"name": "unit-test",
"params": {
"name": "travis/ci"
}
},
{
"type": "check-run",
"name": "secret-detection",
"params": {
"name": "detect-secrets"
}
},
{
"type": "branch-protection",
"name": "code review",
"params": {
"checks": ["travis/ci", "detect-secrets"]
}
},
{
"type": "check-run",
"name": "open-source-license-scan",
"params": {
"name": "ossc/ci"
}
}
]
Esecuzione del comando:
cocoa check pull-request-status
cocoa check pull-request-status \
--branch-protection-settings-output-path <path/to/file> \
--branch-protection-markdown-output-path <path/to/file>
comandi di richiesta di modifica cacao
I comandi cocoa change-request supportano i seguenti provider di gestione modifiche:
- ServiceNow V1
- ServiceNow V3
È possibile specificare il fornitore utilizzando l'opzione --provider con i seguenti valori: servicenow (predefinito) o servicenow-v3.
Ogni fornitore richiede una diversa configurazione della variabile di ambiente:
servicenow:SERVICENOW_TOKEN- Token API ServiceNow V1SERVICENOW_URL- URL API ServiceNow V1
servicenow-v3:PNP_IBMCLOUD_API_KEY- La chiave API per accedere agli endpoint ServiceNow v3, se non fornita, ritorna a IAM_ACCESS_TOKENIAM_ACCESS_TOKEN- Token IBMCloud IAM OAuthSERVICENOW_URL- URL API ServiceNow V3
github-enterprise:GHE_TOKEN- GitHub EnterpriseGITHUB_CHANGE_MANAGEMENT_REPO- GitHubGITHUB_CHANGE_MANAGEMENT_ORG- GitHub Change Management Org
modifica cacao - richiesta get
Interroga una richiesta di modifica dall'API ServiceNow e la salva in un file o la stampa nella console.
Variabili di ambiente richieste per ServiceNow v1 o v2:
SERVICENOW_TOKEN= # ServiceNow API Token
SERVICENOW_URL= # ServiceNow API URL
Variabili di ambiente richieste per ServiceNow v3:
SERVICENOW_URL= # ServiceNow API URL
Variabili di ambiente aggiuntive per ServiceNow v3:
PNP_IBMCLOUD_API_KEY= # API Key to access ServiceNow v3 endpoints, if not provided, falls back to IAM_ACCESS_TOKEN
IAM_ACCESS_TOKEN= # Access token obtained from the IAM service
Variabili di ambiente richieste per GitHub Enterprise:
GHE_TOKEN= # Github Enterprise API Token (only required when parsing from pr)
GITHUB_CHANGE_MANAGEMENT_ORG= # The owner of the repository (optional, when --org is not provided)
GITHUB_CHANGE_MANAGEMENT_REPO= # The repository name (optional, when --repo is not provided)
Variabili di ambiente richieste per Gitlab:
GITLAB_TOKEN= # Gitlab token. (Optional if you are using --git-token-path)
GITLAB_URL= # Change management API URL (Optional if you are using --git-api-url)
Opzioni:
--change-request-id='CHGXXXXXX' # (Required) The Change Request ID to query from ServiceNow.
--output='filename.json' # (Optional) If provided, the Change Request data will be written to this file.
--provider='servicenow' # (Optional) Change Management service provider (choices: 'servicenow', 'servicenow-v3', default: 'servicenow')
Esecuzione del comando:
# Read Change Request with number 'CHG123456' and output the JSON Data to the console.
$ cocoa change-request get --change-request-id='CHG123456'
# Read Change Request with number 'CHG123456' and output the JSON Data to the file named 'cr.json'.
$ cocoa change-request get --change-request-id='CHG123456' --output='cr.json'
# Read Change Request with number 'CHG123456' using the ServiceNow v3 API
$ cocoa change-request get --change-request-id='CHG123456' --provider='servicenow-v3'
modifica cacao - richiesta di creazione
Crea una richiesta di modifica e la invia all'API ServiceNow.
Due metodi di utilizzo:
- Fornire tutti i campi CR richiesti dalle opzioni CLI.
Opzioni:
--assigned-to # A ServiceNow validated user (defaults to value found in the pull request)
--system # the name of the system in ServiceNow
--impact # impact explanation (defaults to value found in th pull request)
--outage-duration # duration of the outage (format: 'd HH:mm:ss' or 'none')
--priority # change priority, valid options: critical, high, moderate, low, planning (defaults to value found in the pull request)
--environment # the environment for the deployment
--purpose # purpose explanation (default to value found in the pull request)
--description # description of the change
--backout-plan # description of the backout plan (defaults to the value found in the PR)
--planned-start # planned start time of the change (required format: YYYY-MM-DD HH:mm:ss, e.g 2020-05-13 13:00:12, in UTC)
--planned-end # planned end time of the change (required format: YYYY-MM-DD HH:mm:ss, e.g 2020-05-13 13:00:12, in UTC)
--deployment-ready # readiness for deployment (choices: 'yes', 'no', default: 'yes')
--type # change request type, option: standard, emergency
--provider # (Optional) Change Management service provider (choices: 'servicenow', 'servicenow-v3', 'github-enterprise', 'gitlab' default: 'servicenow')
--pipeline-name # (Optional) name of the pipeline used for identifying the pipeline
--pipeline-version # (Optional) version of pipeline used (value must match regular expression [0-9.]+)
- Fornire un nome file da cui analizzare i dati della richiesta di modifica. È previsto il formato JSON.
Opzioni:
--file --f # json file name to parse the cr data from
--provider # (Optional) Change Management service provider (choices: 'servicenow', 'servicenow-v3', default: 'servicenow')
File di esempio:
{
"type": "emergency",
"assignedto": "alexandra.szanto@ibm.com",
"backoutplan": "rollback",
"priority": "critical",
"purpose": "bugfix",
"description": "test description",
"environment": "crn:v1:bluemix:public::ch-ctu-2::::",
"impact": "bug",
"system": "devopsinsights",
"outageduration": "0 00:00:00",
"plannedstart": "2020-10-05 14:48:00",
"plannedend": "2020-10-05 14:49:00",
"deploymentready": "yes",
}
Variabili di ambiente richieste per ServiceNow v1 o v2:
SERVICENOW_TOKEN= # ServiceNow API Token
SERVICENOW_URL= # ServiceNow API URL
Variabili di ambiente richieste per ServiceNow v3:
SERVICENOW_URL= # ServiceNow API URL
Variabili di ambiente aggiuntive per ServiceNow v3:
PNP_IBMCLOUD_API_KEY= # API Key to access ServiceNow v3 endpoints, if not provided, falls back to IAM_ACCESS_TOKEN
IAM_ACCESS_TOKEN= # Access token obtained from the IAM service
Variabili di ambiente richieste per GitHub Enterprise:
GHE_TOKEN= # Github Enterprise API Token (only required when parsing from pr)
GITHUB_CHANGE_MANAGEMENT_ORG= # The owner of the repository (optional, when --org is not provided)
GITHUB_CHANGE_MANAGEMENT_REPO= # The repository name (optional, when --repo is not provided)
Esecuzione del comando:
cocoa change-request create --file=test.json
O
$ cocoa change-request create \
--assigned-to=<your-ibm-email> \
--system=<servicenow-configuration-item> \
--impact=<impact description> \
--outage-duration='0 00:00:00' \
--priority=<the-priority> \
--environment=<involved-environment> \
--purpose=<purpose-explanation> \
--description=<description-of-the-change> \
--backout-plan=<description-of-a-backout-plan> \
--planned-start='2020-05-13 13:00:12' \
--planned-end='2020-05-13 13:10:12' \
--deployment-ready=<yes/no> \
--type=<change-type> \
aggiornamento della richiesta di modifica del cacao
Aggiornare una richiesta di modifica esistente utilizzando l'API ServiceNow v3 e stamparla sulla console.
Variabili di ambiente richieste per ServiceNow v3:
SERVICENOW_URL= # ServiceNow API URL
CHANGE_REQUEST_ID= # ID of the Change Request
Variabili di ambiente aggiuntive per ServiceNow v3:
PNP_IBMCLOUD_API_KEY= # API Key to access ServiceNow v3 endpoints, if not provided, falls back to IAM_ACCESS_TOKEN
IAM_ACCESS_TOKEN= # Access token obtained from the IAM service
Opzioni:
--close-notes # (Optional) Any pertinent notes to add to change request closure.
--close-category # (Optional) Change request close notes (choices: 'successful', 'successful_issues', 'unsuccessful', 'cancelled')
--description # (Optional) Description of the change
Esecuzione del comando:
# Update Change Request with sample close-notes, close category and description.
$ cocoa change-request update --close-notes="sample close-note" --close-category="successful" --description="sample change description"
Quando si usa l'opzione descrizione, il comando sostituisce la descrizione esistente con la nuova descrizione. Se l'utente vuole aggiungere del contenuto alla descrizione originale, dovrà estrarre la descrizione esistente e aggiungerla manualmente prima di usare questo comando.
modifica - richiesta modifica - stato - da - implementare
Modifica lo stato di una richiesta di modifica in implement tramite l'API ServiceNow.
Opzioni:
--provider # (Optional) Change Management service provider (choices: 'servicenow', 'servicenow-v3', default: 'servicenow')
Variabili di ambiente richieste indipendentemente dal provider:
CHANGE_REQUEST_ID= # ID of the Change Request
Variabili di ambiente richieste, se si utilizza il provider ServiceNow v1 o v2:
SERVICENOW_TOKEN= # ServiceNow API Token
SERVICENOW_URL= # ServiceNow API URL
Variabili di ambiente richieste, se si utilizza il fornitore ServiceNow v3:
SERVICENOW_URL= # ServiceNow API URL
Ulteriori variabili di ambiente, se si utilizza il fornitore ServiceNow v3:
PNP_IBMCLOUD_API_KEY= # API Key to access ServiceNow v3 endpoints, if not provided, falls back to IAM_ACCESS_TOKEN
IAM_ACCESS_TOKEN= # Access token obtained from the IAM service
Variabili di ambiente richieste per il provider GitHub Enterprise:
GHE_TOKEN= # Github Enterprise API Token (only required when parsing from pr)
GITHUB_CHANGE_MANAGEMENT_ORG= # The owner of the repository (optional, when --org is not provided)
GITHUB_CHANGE_MANAGEMENT_REPO= # The repository name (optional, when --repo is not provided)
Esecuzione del comando:
cocoa change-request change-state-to-implement
modifica cacao - richiedi chiusura
Chiude una richiesta di modifica tramite l'API ServiceNow. È possibile allegare 'chiudi note' utilizzando l'opzione --close-notes e specificare 'chiudi categoria' utilizzando l'opzione --close-category.
Opzioni:
--close-category # Choices: "successful" (default), "successful_issues", "unsuccessful", "cancelled"
--close-notes # String, defaults to "Deployment done."
--provider # (Optional) Change Management service provider (choices: 'servicenow', 'servicenow-v3', default: 'servicenow')
Variabili di ambiente richieste indipendentemente dal provider:
CHANGE_REQUEST_ID= # ID of the Change Request
Variabili di ambiente richieste, se si utilizza il provider ServiceNow v1 o v2:
SERVICENOW_TOKEN= # ServiceNow API Token
SERVICENOW_URL= # ServiceNow API URL
Variabili di ambiente richieste, se si utilizza il fornitore ServiceNow v3:
SERVICENOW_URL= # ServiceNow API URL
Ulteriori variabili di ambiente, se si utilizza il fornitore ServiceNow v3:
PNP_IBMCLOUD_API_KEY= # API Key to access ServiceNow v3 endpoints, if not provided, falls back to IAM_ACCESS_TOKEN
IAM_ACCESS_TOKEN= # Access token obtained from the IAM service
Variabili di ambiente richieste per il provider GitHub Enterprise:
GHE_TOKEN= # Github Enterprise API Token (only required when parsing from pr)
GITHUB_CHANGE_MANAGEMENT_ORG= # The owner of the repository (optional, when --org is not provided)
GITHUB_CHANGE_MANAGEMENT_REPO= # The repository name (optional, when --repo is not provided)
Esecuzione del comando:
cocoa change-request close
Modifica del cacao - richiesta di controllo - approvazione
Interroga lo stato di approvazione di una richiesta di modifica. Se la richiesta di modifica è un'emergenza, il comando non ha esito negativo ma richiede un'approvazione retroattiva.
Opzioni:
--provider # (Optional) Change Management service provider (choices: 'servicenow', 'servicenow-v3', default: 'servicenow')
Variabili di ambiente richieste indipendentemente dal provider:
CHANGE_REQUEST_ID= # ID of the Change Request
Variabili di ambiente richieste, se si utilizza il provider ServiceNow v1 o v2:
SERVICENOW_TOKEN= # ServiceNow API Token
SERVICENOW_URL= # ServiceNow API URL
Variabili di ambiente richieste, se si utilizza il fornitore ServiceNow v3:
SERVICENOW_URL= # ServiceNow API URL
Ulteriori variabili di ambiente, se si utilizza il fornitore ServiceNow v3:
PNP_IBMCLOUD_API_KEY= # API Key to access ServiceNow v3 endpoints, if not provided, falls back to IAM_ACCESS_TOKEN
IAM_ACCESS_TOKEN= # Access token obtained from the IAM service
Variabili di ambiente richieste per il provider GitHub Enterprise:
GHE_TOKEN= # Github Enterprise API Token (only required when parsing from pr)
GITHUB_CHANGE_MANAGEMENT_ORG= # The owner of the repository (optional, when --org is not provided)
GITHUB_CHANGE_MANAGEMENT_REPO= # The repository name (optional, when --repo is not provided)
Esecuzione del comando:
cocoa change-request check-approval
modifica cacao - preparazione richiesta
Crea i dati della richiesta di modifica e li stampa sulla console o su un file.
Variabili di ambiente richieste:
GHE_TOKEN= # Github Enterprise API Token (only required when parsing from pr)
GHE_ORG= # The owner of the repository (optional, when --org is not provided)
GHE_REPO= # The repository name (optional, when --repo is not provided)
EMERGENCY_LABEL= # Emergency Label (optional, when --emergency-label is not provided)
I seguenti campi possono essere analizzati dal corpo della richiesta di pull:
--assigned-to
--impact
--priority
--purpose
--backout-plan
--type
--customer-impact
--deployment-impact
Nel caso in cui vengano forniti utilizzando l'opzione CLI, l'opzione CLI sovrascrive il valore trovato nella richiesta di pull. Se vengono forniti tutti, pr non viene analizzato, --org, --repo e GHE_TOKEN non è necessario.
Opzioni:
--org # github organization where the parsed pr is (only needed if fields are parsed from pr, defaults to GHE_ORG)
--repo # github repository name whre the parsed pr is (only needed if fields are parsed from pr, defaults to GHE_REPO)
--pr # the pull request number to parse (mutually exclusive with sha and branch)
--sha # infer the pr number from hash (mutually exclusive with pr and branch)
--branch # infer PR based on the last merged pr into this branch (defaults to master)
--assigned-to # A ServiceNow validated user (defaults to value found in the pull request)
--system # the name of the system in ServiceNow
--impact # implact explanation (defaults to value found in th pull request)
--outage-duration # duration of the outage
--planned-start # planned start time of the change (required format: YYYY-MM-DD HH:mm:ss, e.g 2020-05-13 13:00:12, in UTC)
--planned-end # planned end time of the change (required format: YYYY-MM-DD HH:mm:ss, e.g 2020-05-13 13:00:12, in UTC)
--priority # change priority, valid options: critical, high, moderate, low, planning (defaults to value found in the pull request)
--environment # the environment for the deployment
--purpose # purpose explanation (default to value found in the pull request)
--backout-plan # description of the backout plan (defaults to the value found in the PR)
--deployment-ready # description of the change
--type # change request type, option: standard, emergency
--emergency-label # emergency label to look for in the pull request
--file # file name to print the cr data to (optional, prints to stdout by default)
--service-environment # service environment of the change, valid options: production, pre_prod
--service-environment-detail # brief description of the service environment where change is deployed.
--pipeline-name # (Required) name of the pipeline used (for example 'onepipeline | continuous-delivery')
--pipeline-version # version of pipeline used (for example '9.22.3')
--validation-record # Pre-prod change request numbers or NA if there is no pre-prod change request for the deployment
Esecuzione del comando:
$ cocoa cr prepare \
--org=<github-organization> \
--repo=<github-repo-name> \
--pr=<pr number>
Richiesta di modifica del cacao - approvazione
Richiede approvazione per i record nel nuovo stato con approvazione non richiesta. Durante l'esecuzione, il record segue il percorso di approvazione manuale.
Opzioni:
--crid="<ID>"
# or
--change-request-id="<ID>"
--provider # (Optional) Change Management service provider (choices: 'servicenow', 'servicenow-v3', default: 'servicenow')
Variabili di ambiente richieste, se si utilizza il provider ServiceNow v1 o v2:
SERVICENOW_TOKEN= # ServiceNow API Token
SERVICENOW_URL= # ServiceNow API URL
Variabili di ambiente richieste, se si utilizza il fornitore ServiceNow v3:
SERVICENOW_URL= # ServiceNow API URL
Ulteriori variabili di ambiente, se si utilizza il fornitore ServiceNow v3:
PNP_IBMCLOUD_API_KEY= # API Key to access ServiceNow v3 endpoints, if not provided, falls back to IAM_ACCESS_TOKEN
IAM_ACCESS_TOKEN= # Access token obtained from the IAM service
Variabili di ambiente richieste per il provider GitHub Enterprise:
GHE_TOKEN= # Github Enterprise API Token (only required when parsing from pr)
GITHUB_CHANGE_MANAGEMENT_ORG= # The owner of the repository (optional, when --org is not provided)
GITHUB_CHANGE_MANAGEMENT_REPO= # The repository name (optional, when --repo is not provided)
Esecuzione del comando:
cocoa change-request request-approval --crid="<insert-change-request-id-here>"
modifica cacao - richiesta di aggiunta
Aggiunge un allegato di modifica ad una specifica richiesta di modifica.
Opzioni:
--description # A more detailed description for the Change Task. [string]
--name # Name of the Change Task. [string] [required]
--data # Data for the Change Task or a path prefixed with @ to read the data from. [string] [default: "@/dev/stdin"]
--provider # (Optional) Change Management service provider (choices: 'servicenow', 'github-enterprise', 'servicenow-v3', default: 'servicenow')
Variabili di ambiente richieste, se si utilizza il provider ServiceNow v1 o v2:
SERVICENOW_TOKEN= # ServiceNow API Token
SERVICENOW_URL= # ServiceNow API URL
Variabili di ambiente richieste, se si utilizza il fornitore ServiceNow v3:
SERVICENOW_URL= # ServiceNow API URL
Ulteriori variabili di ambiente, se si utilizza il fornitore ServiceNow v3:
PNP_IBMCLOUD_API_KEY= # API Key to access ServiceNow v3 endpoints, if not provided, falls back to IAM_ACCESS_TOKEN
IAM_ACCESS_TOKEN= # Access token obtained from the IAM service
Variabili di ambiente richieste per il provider GitHub Enterprise:
GHE_TOKEN= # Github Enterprise API Token (only required when parsing from pr)
GITHUB_CHANGE_MANAGEMENT_ORG= # The owner of the repository (optional, when --org is not provided)
GITHUB_CHANGE_MANAGEMENT_REPO= # The repository name (optional, when --repo is not provided)
Esecuzione del comando:
$ cocoa change-request attachment add "CHGXXXXXXX" \
--name='<attachment-name>' \
--data='<data-for-the-attachment>'
$ cat data.txt | cocoa change-request attachment add "CHGXXXXXXX" --name='<attachment-name>'
$ cocoa change-request attachment add "CHGXXXXXXX" \
--name='<attachment-name>' \
--data='@<path/to/file>'
Modifica cacao - richiesta di allegato get
Ottiene un allegato di modifica specifico di una richiesta di modifica.
Opzioni:
--provider # (Optional) Change Management service provider (choices: 'servicenow', 'servicenow-v3', default: 'servicenow')
Variabili di ambiente richieste, se si utilizza il provider ServiceNow v1 o v2:
SERVICENOW_TOKEN= # ServiceNow API Token
SERVICENOW_URL= # ServiceNow API URL
Variabili di ambiente richieste, se si utilizza il fornitore ServiceNow v3:
SERVICENOW_URL= # ServiceNow API URL
Ulteriori variabili di ambiente, se si utilizza il fornitore ServiceNow v3:
PNP_IBMCLOUD_API_KEY= # API Key to access ServiceNow v3 endpoints, if not provided, falls back to IAM_ACCESS_TOKEN
IAM_ACCESS_TOKEN= # Access token obtained from the IAM service
Variabili di ambiente richieste per il provider GitHub Enterprise:
GHE_TOKEN= # Github Enterprise API Token (only required when parsing from pr)
GITHUB_CHANGE_MANAGEMENT_ORG= # The owner of the repository (optional, when --org is not provided)
GITHUB_CHANGE_MANAGEMENT_REPO= # The repository name (optional, when --repo is not provided)
Esecuzione del comando:
cocoa change-request attachment get "CHGXXXXXXX" "CTASKXXXXXXX"
elenco allegati richiesta di modifica cacao
Elenca gli allegati di modifica per una richiesta di modifica.
Opzioni:
--provider # (Optional) Change Management service provider (choices: 'servicenow', 'servicenow-v3', default: 'servicenow')
Variabili di ambiente richieste, se si utilizza il provider ServiceNow v1 o v2:
SERVICENOW_TOKEN= # ServiceNow API Token
SERVICENOW_URL= # ServiceNow API URL
Variabili di ambiente richieste, se si utilizza il fornitore ServiceNow v3:
SERVICENOW_URL= # ServiceNow API URL
Ulteriori variabili di ambiente, se si utilizza il fornitore ServiceNow v3:
PNP_IBMCLOUD_API_KEY= # API Key to access ServiceNow v3 endpoints, if not provided, falls back to IAM_ACCESS_TOKEN
IAM_ACCESS_TOKEN= # Access token obtained from the IAM service
Variabili di ambiente richieste per il provider GitHub Enterprise:
GHE_TOKEN= # Github Enterprise API Token (only required when parsing from pr)
GITHUB_CHANGE_MANAGEMENT_ORG= # The owner of the repository (optional, when --org is not provided)
GITHUB_CHANGE_MANAGEMENT_REPO= # The repository name (optional, when --repo is not provided)
Esecuzione del comando:
cocoa change-request attachment list "<insert-change-request-id-here>"
modifica cacao - richiesta di aggiornamento allegato
Aggiorna un allegato di modifica in una specifica richiesta di modifica.
Opzioni:
--change-request-id # The change request the change task belongs to [string] [required]
--change-task-id # The change task id to be updated [string] [required]
--description # A more detailed description for the Change Task. [string]
--data # Data for the Change Task or a path prefixed with @ to read the data from. [string]
--provider # (Optional) Change Management service provider (choices: 'servicenow', 'servicenow-v3', default: 'servicenow')
Variabili di ambiente richieste, se si utilizza il provider ServiceNow v1 o v2:
SERVICENOW_TOKEN= # ServiceNow API Token
SERVICENOW_URL= # ServiceNow API URL
Variabili di ambiente richieste, se si utilizza il fornitore ServiceNow v3:
SERVICENOW_URL= # ServiceNow API URL
Ulteriori variabili di ambiente, se si utilizza il fornitore ServiceNow v3:
PNP_IBMCLOUD_API_KEY= # API Key to access ServiceNow v3 endpoints, if not provided, falls back to IAM_ACCESS_TOKEN
IAM_ACCESS_TOKEN= # Access token obtained from the IAM service
Variabili di ambiente richieste per il provider GitHub Enterprise:
GHE_TOKEN= # Github Enterprise API Token (only required when parsing from pr)
GITHUB_CHANGE_MANAGEMENT_ORG= # The owner of the repository (optional, when --org is not provided)
GITHUB_CHANGE_MANAGEMENT_REPO= # The repository name (optional, when --repo is not provided)
Esecuzione del comando:
$ cocoa change-request attachment update
--change-request-id='CHGXXXXXXX' \
--change-attachment-id='CTASKXXXXXXX' \
--data='<data-for-the-attachment>' \
--description='<description>'
$ cat data.txt | cocoa change-request attachment update --change-request-id='CHGXXXXXXX' --change-attachment-id='CTASKXXXXXXX' --data='@/dev/stdin'
$ cocoa change-request attachment update --change-request-id='CHGXXXXXXX' --change-attachment-id='CTASKXXXXXXX' --data='@<path/to/file>'
cacao modifica-richiesta commento aggiungere
Aggiunge un commento a una specifica Richiesta di modifica.
Opzioni:
--comment # Comment to add [string] [required]
--provider # (Optional) Change Management service provider (choices: 'servicenow-v3', 'gitlab', 'github-enterprise', default: 'servicenow-v3')
--git-api-url # (Optional) Git API URL [string]
--git-token-path # (Optional) Git token path to read the secret from [string]
Variabili di ambiente richieste, se si utilizza il fornitore ServiceNow v3:
SERVICENOW_URL= # ServiceNow API URL
Ulteriori variabili di ambiente, se si utilizza il fornitore ServiceNow v3:
PNP_IBMCLOUD_API_KEY= # API Key to access ServiceNow v3 endpoints, if not provided, falls back to IAM_ACCESS_TOKEN
IAM_ACCESS_TOKEN= # Access token obtained from the IAM service
Variabili d'ambiente necessarie per il provider GitLab:
GITLAB_TOKEN= # Gitlab Token
GITLAB_URL= # Gitlab API URL
GITLAB_ORG= # Gitlab ORG
GITLAB_REPO= # Gitlab REPO Name
Variabili di ambiente richieste per il provider GitHub Enterprise:
GHE_TOKEN= # Github Enterprise API Token
GITHUB_CHANGE_MANAGEMENT_ORG= # The owner of the repository
GITHUB_CHANGE_MANAGEMENT_REPO= # The repository name
Esecuzione del comando:
$ cocoa change-request comment add "CHGXXXXXXX" \
--comment='This is a comment for the change request'
$ cocoa change-request comment add "CHGXXXXXXX" \
--comment='Adding comment using GitLab provider' \
--provider='gitlab'
comandi prova cacao
Formato prova cacao - riepilogo
Formatta il riepilogo delle prove in formato leggibile. Può essere inserito nel contenuto della richiesta di modifica.
Esecuzione del comando:
$ cocoa evidence format-summary \
--input=<filepath> \ # (default: -, referring to stdin) If present, the formatted evidence will be read from the given file.
--output=<filepath> # (default: -, referring to stdout) If present, the formatted evidence will be saved to the given file.
# Reading from stdin and printing to stdout:
$ cat raw-summary.json | cocoa evidence format-summary -i - -o - | tee formatted-summary.txt
$ cat raw-summary.json | cocoa evidence format-summary | tee formatted-summary.txt
# Reading to and from file:
$ cocoa evidence format-summary --input=raw-summary.json --output=formatted-summary.txt
ribasso delle prove di cacao - riepilogo
Formatta il riepilogo delle prove in un formato di ribasso che può essere fornito come commento della richiesta di pull GitHub.
L'input è un riepilogo non elaborato e può essere in uno dei seguenti due formati:
- Riepilogo in formato JSON.
- Riepilogo aggregato, che è un array JSON di riepiloghi di singole app.
Quando un riepilogo aggregato viene passato come input, l'output raggruppa lo stato della prova in base alle app nei riepiloghi.
Indicatore facoltativo:
--detailed: viene generato un riepilogo dettagliato del ribasso se l'indicatore è impostato su true (per impostazione predefinita,trueè impostato sufalseper un riepilogo ridotto).
Esecuzione del comando:
$ cocoa evidence markdown-summary \
--input=<filepath> \ # (default: -, referring to stdin) If present, the formatted evidence will be read from the given file.
--output=<filepath> # (default: -, referring to stdout) If present, the formatted evidence will be saved to the given file.
# Reading from stdin and printing to stdout:
$ cat raw-summary.json | cocoa evidence markdown-summary -i - -o - | tee markdown-summary.md
$ cat aggr-summary.json | cocoa evidence markdown-summary | tee markdown-summary.md
# Reading to and from file:
$ cocoa evidence markdown-summary --input=raw-summary.json --output=markdown-summary.md
comandi risorsa utente cacao
caricamento risorsa cacao
Carica una risorsa utente nei backend specificati. I backend possono essere diversi tipi di locker delle prove, ad esempio Object Storage, GitHub o DevOps Insights. Armadietti differenti richiedono parametri differenti da fornire.
Opzioni:
--backend # (Required) Specifies the types of lockers we upload the artifact ('cos', 'git')
--pipeline-run-id # The ID of the PipelineRun running the CLI command
--namespace # Specifies the pipeline the evidence is collected from
--upload-path # If present, this overrides the artifact name with the specified value
--is-summary # If present, this uploads the artifact to the location where evidence summary is usually stored
Opzioni per Git:
--git-token-path #(Optional) Github Token's path
--git-api-url #(Optional) Github API url
Variabili di ambiente richieste:
PIPELINE_RUN_ID= # Can be used instead of '--pipeline-run-id' option
NAMESPACE= # Can be used instead of '--namespace' option
Variabili di ambiente obbligatorie, se si utilizza il provider 'git':
EVIDENCE_REPO_ORG= # The Git repo org (Required if you are using 'git' backend)
EVIDENCE_REPO_NAME= # The Git repo name (Required if you are using 'git' backend)
Variabili d'ambiente richieste, se si utilizzaGitHub:
GHE_TOKEN= # Github Enterprise API Token (Optional if you are using --git-token-path)
Variabili di ambiente obbligatorie, se si utilizza Cloud Object Storage:
COS_API_KEY= # Cloud Object Storage API Key (Required if you are using 'cos' backend)
COS_BUCKET_NAME= # Bucket Name where the artifact will be uploaded in the COS Instance (Required if you are using 'cos' backend)
COS_ENDPOINT= # The COS API Endpoint matching the region where the bucket is located (Required if you are using 'cos' backend)
Se si usa github, usare il campo --git-token-path per impostare il token GitHub e il campo --git-api-url per impostare l' URL dell'API GitHub Enterprise, invece delle variabili d'ambiente GHE_TOKEN e GH_URL. Se vengono fornite entrambe le coppie GHE_TOKEN GH_URL e --git-token-path --git-api-url, --git-token-path e --git-api-url hanno la precedenza.
Esecuzione del comando:
$ cocoa artifact upload
$ cocoa artifact upload \
--backend=[choices: "git", "cos"] \ # e.g. --backend=cos,git
--pipeline-run-id=<pipeline-run-id> # can be substituted by PIPELINE_RUN_ID
--namespace=[choices: "ci", "cd"] \ # Pipeline type the evidence was collected from, can be substituted by NAMESPACE
--is-summary # If present, this uploads the artifact to the location where evidence summary is usually stored
<file-path>
Le opzioni CLI possono essere impostate anche dalle variabili di ambiente ad eccezione di backend e upload-path.
Recupero di un reperto
Puoi recuperare artefatti da vari armadietti delle prove, come Object Storage, GitHub, o DevOps Insights, utilizzando il comando cocoa artifact get. Questo comando consente di recuperare artefatti da diversi tipi di armadietti, ognuno dei quali richiede parametri specifici.
Il comando " cocoa artifact get " recupera un artefatto dai backend specificati. Armadietti differenti richiedono parametri differenti da fornire. Opzioni:
--backend # Specifies the types of locker to retrieve the artifact from ('cos', 'git')
--artifact-prefix # Path where the artifact is present. To be used in COS only, not available in Git. (Use this or --artifact-path, can't be used together)
--artifact-path # Absolute path on where the artifact is present.
--is-summary # If present, this returns the merged summary from all the file paths.
Opzioni per Git:
--git-token-path # Github Token's path
--git-api-url # (Optional) Github API url
Variabili di ambiente richieste:
Variabili di ambiente obbligatorie, se si utilizza il provider 'git':
EVIDENCE_REPO_ORG= # The Git repo org (Required if you are using 'git' backend)
EVIDENCE_REPO_NAME= # The Git repo name (Required if you are using 'git' backend)
Variabili d'ambiente richieste, se si utilizzaGitHub:
GHE_TOKEN= # Github Enterprise API Token (Optional if you are using --git-token-path)
Variabili di ambiente obbligatorie, se si utilizza Cloud Object Storage:
COS_API_KEY= # Cloud Object Storage API Key (Required if you are using 'cos' backend)
COS_BUCKET_NAME= # Bucket Name where the artifact will be uploaded in the COS Instance (Required if you are using 'cos' backend)
COS_ENDPOINT= # The COS API Endpoint matching the region where the bucket is located (Required if you are using 'cos' backend)
BACKUP_COS_API_KEY= # Cloud Object Storage API Key (Required while migrating from one COS bucket to another to read the old artifacts)
BACKUP_COS_BUCKET_NAME= # Bucket Name where the artifact will be uploaded in the COS Instance (Required while migrating from one COS bucket to another to read the old artifacts)
BACKUP_COS_ENDPOINT= # The COS API Endpoint matching the region where the bucket is located (Required while migrating from one COS bucket to another to read the old artifacts)
Se si usa github, usare il campo --git-token-path per impostare il token GitHub e il campo --git-api-url per impostare l' URL dell'API GitHub Enterprise, invece delle variabili d'ambiente GHE_TOKEN e GH_URL. Se vengono fornite entrambe le coppie GHE_TOKEN GH_URL e --git-token-path --git-api-url, --git-token-path e --git-api-url hanno la precedenza.
Esecuzione del comando:
$ cocoa artifact get
$ cocoa artifact get \
--backend=[choices: "git", "cos"] \ # e.g. --backend=cos
--artifact-path <file-path> \ # full path in case of git, cos can utilise --artifact-prefix <file-path>
Le opzioni CLI possono essere impostate anche dalle variabili d'ambiente, ad eccezione di backend e artifact-path / artifact-prefix.
stato set di cacao
Imposta lo stato di un commit. L'implementazione corrente viene verificata su GitHub. Vedi la documentazione sugli stati diGitHub.
Variabili di ambiente richieste:
GHE_ORG= # Github organization/username
GHE_REPO= # Github repository
GHE_COMMIT= # Github commit hash
Variabili d'ambiente richieste, se si utilizzaGitHub:
GHE_TOKEN= # Github token (Optional if you are using --git-token-path)
Se si usa github, usare il campo --git-token-path per impostare il token GitHub e il campo --git-api-url per impostare l' URL dell'API GitHub Enterprise, invece delle variabili d'ambiente GHE_TOKEN e GH_URL. Se vengono fornite entrambe le coppie GHE_TOKEN GH_URL e --git-token-path --git-api-url, --git-token-path e --git-api-url hanno la precedenza.
Opzioni per Git:
--git-token-path #(Optional) GitHub token's path
--git-api-url #(Optional) GitHub API url
Esecuzione del comando:
$ cocoa set-status \
--state="pending" \
--targetURL="https://cloud.ibm.com/devops/pipelines/tekton/some-toolchain/runs/some-pipelinerun/lint/lint?env_id=ibm:yp:us-south" \
--context="tekton/lint" \
--description="Tekton linter is running."
comandi inventario cacao
aggiunta inventario cacao
Aggiunge un valore al repository di inventario. Crea un file con l'opzione name, se non esiste, altrimenti lo sovrascrive.
Variabili di ambiente richieste:
GHE_ORG= # Github Organization (required if --org option is not specified).
GHE_REPO= # Github Repository (required if --repo option is not specified).
Variabili d'ambiente richieste, se si utilizzaGitHub:
GHE_TOKEN= # Github Enterprise API Token(Optional if you are using --git-token-path)
Opzioni per Git:
--git-token-path #(Optional) Github Token's path
--git-api-url #(Optional) Github API url
| Opzione | Descrizione | Tipo di valore | Obbligatoria o facoltativa | Valore/i possibile/i / Valore predefinito / Osservazioni |
|---|---|---|---|---|
| risorsa utente | Nome dell'artefatto creato per l'applicazione. | Stringa | Obbligatorio | Se il tipo di artefatto è un'immagine, utilizzare il seguente formato: <static_name>:<version>@sha256:<sha256_digest> OPPURE <static_name>@sha256:<sha256_digest>. Se il tipo di voce non è un'immagine, utilizzare un nome statico che rimanga invariato in tutti gli aggiornamenti della voce. |
| versione | La versione dell'applicazione. | Stringa | Obbligatorio |
|
| url - repository | L' URL che punta al repository del codice sorgente dell'applicazione (di github o di GRIT/gitlab) | Stringa | Obbligatorio | Dovrebbe essere un repository di codice sorgente valido (come github / gitlab) e non un repository di docker (come artifactory) |
| id - esecuzione - pipeline | L'id dell'esecuzione della pipeline. | Stringa | Obbligatorio | Viene utilizzato per individuare le prove. Dovrebbe essere l'id o l'uuid della pipeline. (Valore di esempio: " f21321af-9084-4af3-80b8-4fb34143b7d9 ) |
| SHA del commit | Il commit del repository dell'applicazione da cui viene costruito l'artefatto. | Stringa | Obbligatorio | Dovrebbe essere un commit sha di formato lungo (40 caratteri minuscoli) |
| nome | Il nome dell'applicazione a cui appartiene la risorsa utente | Stringa | Obbligatorio | È un settore unico nel suo genere. Si possono usare sottodirectory, come name=subdir/foo, che possono rendere il repository dell'inventario meglio organizzato. |
| numero - build | Il numero della build. | number | Obbligatorio | Il numero di build viene utilizzato per correlare l'artefatto di build e l'artefatto di distribuzione |
| org | L'organizzazione GitHub che possiede il repository di inventario. | Stringa | Opzionale se è impostata la variabile d'ambiente GHE_ORG |
|
| repo | Il nome del repository dell'inventario. | Stringa | Opzionale se è impostata la variabile d'ambiente GHE_REPO |
|
| App - risorse utente | Contenuto app arbitrario in formato JSON | Stringa | Facoltativo | Qualsiasi contenuto aggiuntivo può essere aggiunto qui per l'automazione/il flusso di lavoro |
| Immettere | Tipo di artefatto. Può essere "image" per le immagini, oppure può essere un valore statico per i tipi generici come i file di distribuzione, i diagrammi di timone, ecc. | Stringa | Obbligatorio | Valori possibili: ["image"] per artefatti di tipo immagine, ' altrimenti si possono usare valori come ["helm-chart", "deployment-file"] o qualsiasi altro valore arbitrario |
| sha256 | L'hash sha256 dell'artefatto. | Stringa | Obbligatorio | Deve essere del formato " sha256:<64 character hash> |
| Provenienza | URL che punta all'artefatto (ad esempio, l'immagine costruita). | Stringa | Obbligatorio | Per una voce d'inventario di tipo "immagine", la provenienza deve essere la stessa del campo artefatto |
| firma | La firma della risorsa utente | Stringa | Obbligatorio |
|
| ambiente | Il nome dell'ambiente in cui viene aggiunta la voce. | Stringa | Facoltativo | Valore predefinito: "master" |
| dal file | Il nome del file che contiene i dettagli delle voci dell'inventario. Usare questo flag per caricare più voci dell'inventario in un singolo commit sul repo dell'inventario. | stringa | Facoltativo | Esempio: path/to/file.json |
| git-provider | Il provider del servizio di controllo versione Git. | Stringa | Facoltativo | Predefinito: "github" Valori possibili: ["github", "gitlab"] |
| percorso - token - git | Percorso token Git da cui leggere il segreto | Stringa | Opzionale se è impostata la variabile d'ambiente GHE_TOKEN | Esempio: path/to/git-token |
| url - api - git | URL API Git | Stringa | Facoltativo | Predefinito : " https://<region>.git.cloud.ibm.com/api/v4 |
| ubicazione | Posizione dell'artefatto in altri registri, insieme all'indirizzo sha256 | Stringa | Facoltativo | Esempio: <environment>#<static_name>:<version>@sha256:<sha256_digest>. È possibile specificare questa opzione più volte. |
Esecuzione del comando:
$ cocoa inventory add \
--artifact=us.icr.io/namespace/hello-compliance-app:20201217081811-master-b85e3d472e9cc35b429c39e8c3f9eb282738c20a@sha256:da36831d5154307ac9ca4b8d900df2da0c6c14754977c32479dc62994b5722d0 \
--type=image \
--sha256=sha256:786800e8e48938664fe2397ca14ab8dabd48f34656ef5cfda4143b4519cb714f \
--name=hello-compliance-app \
--repository-url=https://github.com/test-org/compliance-app-20201211 \
--commit-sha=8e86dc4647ce28632103dce46b756c70d339349a \
--version=v4 \
--build-number=33 \
--pipeline-run-id=f21321af-9084-4af3-80b8-4fb34143b7d9 \
--git-token-path=./git-token \
--org=test-org \
--app-artifacts='{"app": "test", "some_value": "value"}' \
--repo=compliance-inventory-repo
--signature=owFNUX1IE3EY3vwAEy0VyoSJdkVWtu0+d3eTjNIIi0jETCSU3353cz+83V23myi2BlFgYiUFqSmZLciUzCJkRYJp9IEWFWXB0hAyrBQxEjIIuhFSf70vL8/7vM/zPi3JsaYEc+TnbqG8qrnTPDZ8w2WqiqwtacCghnQEgYQ5GzAkiLKO9PpoLyiwRtSsmugWNVGGIubE/D4bgpoNKXag60gCdo8oSYoVKl5VQsDAWIGqOkmcxAmSYHGO4AjC6gU+3eBxcYxICTRLijyEFOOiSR5SvMhBys2LLpIjWYqDJA6wwHYMeUG1+J8GL5CRW/TpVgFVG8VQ4vMAknE4BUA5OIoQGIKhKZwFkIeAdnECj+OCmxQADh2QoFmG5lkWUiTN8gJ0kDxPuxiWJAU8ekyvV6PegK54EcyGiqwDJItatg9Vy0D3a2IUpKg6UuS/T4KaaIC1fzuMDbfhmMGEvIY64FUxJ+Ew3PMU5SADgdNmKs5kTjBlrtsQ99iyY49nns8o6jsXWgkjPiYahClxVcrK5Flngumz2j7YdmD0ecutytsvxxNPHflKlRV2RyqD69NjC6Smji9XuukFyZ+lvM18gUr7F4NXge9YyZPik411tc1n9bKO/hDz7oGaX/ur94OnNHiwOG6n5ZsrsCsvtyvmkH4zOWlrRWuL7fzgj9zlcCTAhtu2LbeGLNfv3Ju0Jc9PZPk7Pm3Ov2CW+2xj8ReX6ooGamZ610yqRM/+8Qo2XnOeyZzbVKgs+f2+9unpJOve4Tmla+PdqftDWkHPm9Vq3nsyZ2DUkmP/nTb7qNw5l2SfWtiSemJx9nLaYOpx6amlOT18aeIwJQhHg1XOjJF9r18NXQvPuL9rH5tSQqbGhyN/AA== \
--location=stage#stage-us.icr.io/namespace/hello-compliance-app:20201217081811-master-b85e3d472e9cc35b429c39e8c3f9eb282738c20a@sha256:da36831d5154307ac9ca4b8d900df2da0c6c14754977c32479dc62994b5722d0
$ cocoa inventory add \
--environment=staging \
--artifact=foo-helm-chart/foo/chart.yaml \
--repository-url=https://github.com/test-org/compliance-app-20201211 \
--provenance=https://github.com/test-org/compliance-app-20201211/foo-helm-chart/foo/chart.yaml \
--commit-sha=786800e8e48938664fe2397ca14ab8dabd48f34656ef5cfda4143b4519cb714f \
--build-number=33 \
--pipeline-run-id=f21321af-9084-4af3-80b8-4fb34143b7d9 \
--version=v4 \
--name=foo-app-helm-chart \
--sha256=sha256:9106cdf8c0f5c110f1cdf65825edd195927cdb439db8767791ac2011c2d41894 \
--signature=9106cdf8c0f5c110f1cdf65825edd195927cdb439db8767791ac2011c2d41894 \
--type=helm-chart
$ cocoa inventory add --from-file multi-artifacts.json \
--environment=environment \
--org=test \
--repo=repository
Utilizzo dell'opzione --from-file
Quando si usa l'opzione --from-file, il comando supporta l'aggiunta di più voci in un singolo commit. Questa opzione si aspetta un file JSON contenente un array di oggetti, dove ogni oggetto dell'array deve avere gli stessi
campi descritti nella tabella delle opzioni precedente. I requisiti dei campi (obbligatori o facoltativi) rimangono invariati rispetto all'uso delle singole opzioni della riga di comando. L'unica differenza è che invece di fornire questi
campi come argomenti della riga di comando, vengono letti dal file JSON.
Le opzioni --environment, --org e --repo devono essere fornite sulla riga di comando e si applicano a tutte le voci del file.
Esempio di struttura del file JSON:
[
{
"artifact": "us.icr.io/namespace/hello-compliance-app:20201217081811-master-b85e3d472e9cc35b429c39e8c3f9eb282738c20a@sha256:da36831d5154307ac9ca4b8d900df2da0c6c14754977c32479dc62994b5722d0",
"type": "image",
"sha256": "sha256:786800e8e48938664fe2397ca14ab8dabd48f34656ef5cfda4143b4519cb714f",
"name": "hello-compliance-app",
"repository-url": "https://github.com/test-org/compliance-app-20201211",
"commit-sha": "8e86dc4647ce28632103dce46b756c70d339349a",
"version": "v4",
"build-number": 33,
"pipeline-run-id": "f21321af-9084-4af3-80b8-4fb34143b7d9",
"provenance": "us.icr.io/namespace/hello-compliance-app:20201217081811-master-b85e3d472e9cc35b429c39e8c3f9eb282738c20a@sha256:da36831d5154307ac9ca4b8d900df2da0c6c14754977c32479dc62994b5722d0",
"signature": "owFNUX1IE3EY3vwAEy0VyoSJdkVWtu0+d3eTjNIIi0jETCSU3353cz+83V23myi2BlFgYiUFqSmZLciUzCJkRYJp9IEWFWXB0hAyrBQxEjIIuhFSf70vL8/7vM/zPi3JsaYEc+TnbqG8qrnTPDZ8w2WqiqwtacCghnQEgYQ5GzAkiLKO9PpoLyiwRtSsmugWNVGGIubE/D4bgpoNKXag60gCdo8oSYoVKl5VQsDAWIGqOkmcxAmSYHGO4AjC6gU+3eBxcYxICTRLijyEFOOiSR5SvMhBys2LLpIjWYqDJA6wwHYMeUG1+J8GL5CRW/TpVgFVG8VQ4vMAknE4BUA5OIoQGIKhKZwFkIeAdnECj+OCmxQADh2QoFmG5lkWUiTN8gJ0kDxPuxiWJAU8ekyvV6PegK54EcyGiqwDJItatg9Vy0D3a2IUpKg6UuS/T4KaaIC1fzuMDbfhmMGEvIY64FUxJ+Ew3PMU5SADgdNmKs5kTjBlrtsQ99iyY49nns8o6jsXWgkjPiYahClxVcrK5Flngumz2j7YdmD0ecutytsvxxNPHflKlRV2RyqD69NjC6Smji9XuukFyZ+lvM18gUr7F4NXge9YyZPik411tc1n9bKO/hDz7oGaX/ur94OnNHiwOG6n5ZsrsCsvtyvmkH4zOWlrRWuL7fzgj9zlcCTAhtu2LbeGLNfv3Ju0Jc9PZPk7Pm3Ov2CW+2xj8ReX6ooGamZ610yqRM/+8Qo2XnOeyZzbVKgs+f2+9unpJOve4Tmla+PdqftDWkHPm9Vq3nsyZ2DUkmP/nTb7qNw5l2SfWtiSemJx9nLaYOpx6amlOT18aeIwJQhHg1XOjJF9r18NXQvPuL9rH5tSQqbGhyN/AA==",
"app-artifacts": "{\"app\": \"test\", \"some_value\": \"value\"}",
"locations": {
"stage":"stage-us.icr.io/namespace/hello-compliance-app:20201217081811-master-b85e3d472e9cc35b429c39e8c3f9eb282738c20a@sha256:da36831d5154307ac9ca4b8d900df2da0c6c14754977c32479dc62994b5722d0",
"prod":"prod-us.icr.io/namespace/hello-compliance-app:20201217081811-master-b85e3d472e9cc35b429c39e8c3f9eb282738c20a@sha256:da36831d5154307ac9ca4b8d900df2da0c6c14754977c32479dc62994b5722d0"
},
},
{
"artifact": "foo-helm-chart/foo/chart.yaml",
"repository-url": "https://github.com/test-org/compliance-app-20201211",
"provenance": "https://github.com/test-org/compliance-app-20201211/foo-helm-chart/foo/chart.yaml",
"commit-sha": "786800e8e48938664fe2397ca14ab8dabd48f34656ef5cfda4143b4519cb714f",
"build-number": 34,
"pipeline-run-id": "f21321af-9084-4af3-80b8-4fb34143b7d9",
"version": "v4",
"name": "foo-app-helm-chart",
"sha256": "sha256:9106cdf8c0f5c110f1cdf65825edd195927cdb439db8767791ac2011c2d41894",
"signature": "9106cdf8c0f5c110f1cdf65825edd195927cdb439db8767791ac2011c2d41894",
"type": "helm-chart",
}
]
Quando si usa --from-file, è possibile fornire posizioni per l'artefatto in altri registri. Il comando si aspetta che il campo locations sia un oggetto in cui la chiave è <environment> e il valore
è <static_name>:<version>@sha256:<sha256_digest> in questo formato.
Ottieni inventario cacao
Richiama una voce dal repository di inventario. La destinazione può essere una specifica versione o un ambiente. Utilizzare --version o --environment e utilizzare solo uno di essi. Se manca l'opzione --property,
viene stampato l'intero contenuto della voce di inventario.
Variabili d'ambiente richieste, se si utilizzaGitHub:
GHE_TOKEN= # Github Enterprise API Token (Optional if you are using --git-token-path)
Opzioni per Git:
--git-token-path #(Optional) Github Token's path
--git-api-url #(Optional) Github API url
Se si usa github, usare il campo --git-token-path per impostare il token GitHub e il campo --git-api-url per impostare l' URL dell'API GitHub Enterprise, invece delle variabili d'ambiente GHE_TOKEN e GH_URL. Se vengono fornite entrambe le coppie GHE_TOKEN GH_URL e --git-token-path --git-api-url, --git-token-path e --git-api-url hanno la precedenza.
Per impostazione predefinita, la CLI su ogni richiamo ti garantisce di lavorare con una versione aggiornata di un locker Git. Questo comportamento può essere disabilitato impostando COCOA_USE_CACHE su qualsiasi valore tranne 0,
false, no o n. In questo caso, la CLI utilizza la propria cache interna per ricercare le prove (molto più velocemente), ma i risultati potrebbero essere obsoleti.
Esecuzione del comando:
# Uses the environment as target, and pretty-prints only a given property of the inventory entry to the console.
$ cocoa inventory get \
--org='Github-ID' \
--repo='compliance-inventory-repo' \
--entry='hello-compliance-app' \
--environment='master' \
--property='name'
# Uses the version as target, and pretty-prints the whole content of the inventory entry to the console.
$ cocoa inventory get \
--org='Github-ID' \
--repo='compliance-inventory-repo' \
--entry='hello-compliance-app' \
--version='v1'
get dell'inventario del cacao - sha
Richiama l'ultimo hash di commit da un'etichetta o da un ambiente dal repository di inventario. Utilizzare --label o --environment e utilizzare solo uno di essi.
Variabili d'ambiente richieste, se si utilizzaGitHub:
GHE_TOKEN= # Github Enterprise API Token (Optional if you are using --git-token-path)
Opzioni per Git:
--git-token-path #(Optional) Github Token's path
--git-api-url #(Optional) Github API url
Se si usa github, usare il campo --git-token-path per impostare il token GitHub e il campo --git-api-url per impostare l' URL dell'API GitHub Enterprise, invece delle variabili d'ambiente GHE_TOKEN e GH_URL. Se vengono fornite coppie GHE_TOKEN GH_URL e --git-token-path --git-api-url, --git-token-path e --git-api-url hanno la precedenza.
Esecuzione del comando:
# Get the latest commit hash of the staging branch
$ cocoa inventory get-sha \
--org='Github-ID' \
--repo='compliance-inventory-repo' \
--environment='staging'
# Get the commit hash of the "pipeline-run-id" label
$ cocoa inventory get-sha \
--org='Github-ID' \
--repo='compliance-inventory-repo' \
--label='pipeline-run-id'
etichetta inventario cacao
L'uso di un'etichetta d'inventario consente di aggiungere o spostare le etichette all'interno di un elemento dell'inventario, puntando all'ultimo commit su un ramo o su un'altra etichetta.
Opzioni:
--org # The Github organisation which owns the inventory repository.
--repo # The name of the inventory repository.
--environment # The inventory branch ( not required for deleting a cocoa inventory label)
--to-label # Another label in the inventory that can be referenced or removed. ( not required for deleting a cocoa inventory label )
Variabili di ambiente richieste:
GHE_ORG= # Github Organization (required if --org option is not specified).
GHE_REPO= # Github Repository (required if --repo option is not specified).
Variabili d'ambiente richieste, se si utilizzaGitHub:
GHE_TOKEN= # Github Enterprise API Token (Optional if you are using --git-token-path)
Opzioni per Git:
--git-token-path #(Optional) Github Token's path
--git-api-url #(Optional) Github API url
Se si usa github, usare il campo --git-token-path per impostare il token GitHub e il campo --git-api-url per impostare l' URL dell'API GitHub Enterprise, invece delle variabili d'ambiente GHE_TOKEN e GH_URL. Se vengono fornite entrambe le coppie GHE_TOKEN GH_URL e --git-token-path --git-api-url, --git-token-path e --git-api-url hanno la precedenza.
Esecuzione del comando:
# label the latest state on "staging" branch
$ cocoa inventory label add \
--org='Github-ID' \
--repo='compliance-inventory-repo' \
--environment='staging' \
"new-label-to-add"
# attach a label to another label (to the same commit)
$ cocoa inventory label add \
--org='Github-ID' \
--repo='compliance-inventory-repo' \
--to-label="some-label" \
"new-label-to-add"
# move or create the `label-to-move` label to another label (to the same commit)
$ cocoa inventory label move \
--org='Github-ID' \
--repo='compliance-inventory-repo' \
--to-label="some-label" \
"label-to-move"
# delete the `label-to-delete` label from the inventory
$ cocoa inventory label delete \
--org='Github-ID' \
--repo='compliance-inventory-repo' \
"label-to-delete"
promozione inventario cacao
Promuove le voci dall'inventario da un ambiente all'altro. L'ambiente di origine può essere un ramo o un tag.
Variabili di ambiente richieste:
GHE_ORG= # Github Organization (required if --org option is not specified).
GHE_REPO= # Github Repository (required if --repo option is not specified).
PIPELINE_RUN_ID= # Can be used instead of --pipeline-run-id (either the option or the variable is required).
Variabili d'ambiente richieste, se si utilizzaGitHub:
GHE_TOKEN= # Github Enterprise API Token (Optional if you are using --git-token-path)
Opzioni per Git:
--git-token-path #(Optional) Github Token's path
--git-api-url #(Optional) Github API url
Se si usa github, usare il campo --git-token-path per impostare il token GitHub e il campo --git-api-url per impostare l' URL dell'API GitHub Enterprise, invece delle variabili d'ambiente GHE_TOKEN e GH_URL. Se vengono forniti entrambi, --git-token-path e --git-api-url hanno la precedenza.
Esecuzione del comando:
$ cocoa inventory promote \
--org='Github-ID' \
--repo='compliance-inventory-repo' \
--source='master' \
--target='prod' \
--priority='Critical' \
--assigned-to='employee@ibm.com' \
--description='desc' \
--purpose='purpose' \
--impact='impact' \
--customer-impact='impact' \
--deployment-impact='small' \
--backout-plan='rollback'
convalidare l'inventario del cacao
Convalida le voci presenti in un repo di inventario (o in un file JSON). Il repo dell'inventario può essere convalidato nell'ambiente (ramo) o nell'etichetta (tag).
Le opzioni da convalidare includono (almeno uno dei flag deve essere utilizzato)
- utilizzando il flag '
--environment, che prende come valore un ramo e convalida tutte le voci in esso contenute. - utilizzando il flag '
--label, che prende come valore il tag e convalida tutte le voci in esso contenute. - utilizzando il flag '
--from-file, che prende il percorso di un file JSON contenente le voci dell'inventario (in formato sillabato).
Facoltativo:
- Se si deve usare un nome di file personalizzato per l'inventario, si può usare il flag '
--inventory-ignore-file-nameper ignorare il valore predefinito. - Se esiste già un repo di inventario clonato e si desidera che il comando lo utilizzi, si può fornire il percorso del repo di inventario clonato usando il flag '
--inventory-path.
Opzioni richieste:
--org # The Github organisation which owns the inventory repository.
--repo # The name of the inventory repository.
--environment # The inventory branch to validate
--label # label in the inventory, that will be validated
Variabili d'ambiente (facoltative e possono essere usate al posto di --org --repo e --git-token-path)
GHE_ORG= # Can be used instead of --org (either the option or the variable is required)
GHE_REPO= # Can be used instead of --repo (either the option or the variable is required)
GHE_TOKEN= # Github Enterprise API Token (Optional if using --git-token-path)
Esecuzione del comando:
$ cocoa inventory validate \
--org "Github-ID" \
--repo "inventory-repo" \
--git-token-path="$INVENTORY_TOKEN_PATH" \
--label "$latest_tag" \
--inventory-path "${DIRECTORY_NAME}"
inventario del cacao get-delta
Ottiene il delta tra i commit del repository dell'inventario. Ottenere facoltativamente i commit di revisione tra pari entro il delta tra due commit.
Variabili di ambiente richieste:
GHE_ORG= # Github Organization (required if --org option is not specified).
GHE_REPO= # Github Repository (required if --repo option is not specified).
Variabili d'ambiente richieste, se si utilizzaGitHub:
GHE_TOKEN= # Github Enterprise API Token(Optional if you are using --git-token-path)
Opzioni per Git:
--git-token-path #(Optional) Github Token's path
--git-api-url #(Optional) Github API url
| Opzione | Descrizione | Tipo di valore | Obbligatoria o facoltativa | Valore/i possibile/i / Valore predefinito / Osservazioni |
|---|---|---|---|---|
| da-sha | L'impegno iniziale per calcolare il delta da | Stringa | facoltativo |
|
| dall'etichetta | Il tag da usare come commit iniziale per calcolare il delta da | Stringa | facoltativo |
|
| to-sha | L'impegno finale per calcolare il delta fino a | Stringa | facoltativo |
|
| all'ambiente | Il commit HEAD del ramo dell'ambiente per calcolare il delta fino a | Stringa | facoltativo |
|
| da etichettare | Il tag che indica il commit finale per calcolare il delta fino a | Stringa | facoltativo |
|
| org | L'organizzazione GitHub che possiede il repository di inventario. | Stringa | Opzionale se è impostata la variabile d'ambiente GHE_ORG |
|
| repo | Il nome del repository dell'inventario. | Stringa | Opzionale se è impostata la variabile d'ambiente GHE_REPO |
|
| git-provider | Il provider del servizio di controllo versione Git. | Stringa | Facoltativo | Predefinito: "github" Valori possibili: ["github", "gitlab"] |
| percorso - token - git | Percorso token Git da cui leggere il segreto | Stringa | Opzionale se è impostata la variabile d'ambiente GHE_TOKEN | Esempio: path/to/git-token |
| url - api - git | URL API Git | Stringa | Facoltativo | Predefinito : " https://<region>.git.cloud.ibm.com/api/v4 |
| delta | Flag per calcolare il delta | Booleano | facoltativo | false |
| delta-cancellazione | Flag per calcolare le cancellazioni delta | Booleano | facoltativo | false |
| elenco inventariale | Flag per calcolare l'intero elenco dell'inventario | Booleano | facoltativo | false |
| revisione paritaria | Flag per calcolare i commit della revisione paritaria | Booleano | facoltativo | false |
| percorso del repository | Percorso opzionale del repo dell'inventario. Se viene passato, il repo dell'inventario non viene clonato all'interno del comando | Stringa | facoltativo | |
| percorso del file di inventario | Percorso opzionale per il file di ignoranza dell'inventario | Stringa | facoltativo | |
| precedente-inventario- ignora-percorso-file | Percorso opzionale per il file ignore dell'inventario di distribuzione precedente | Stringa | facoltativo |
Esecuzione del comando:
$ cocoa inventory get-delta \
--git-provider=github \
--git-token-path=./git-token \
--org=test-org \
--repo=compliance-inventory-repo \
--git-api-url=<git-api-url> \
--to-sha 534ff2bbbf0291e10f3b1f6aa409d8de059bbe27 \
--from-sha e54b5aa12ccb687020ac04b16d489b5a04f90399 \
--inventory-ignore-file-path=/path/to/current/.inventoryignore \
--previous-inventory-ignore-file-path=/path/to/previous/.inventoryignore \
--delta \
--delta-deletion \
--inventory-list \
--peer-review
aggiornamento dell'inventario del cacao
Aggiornare una voce/posizione di un artefatto nel repository dell'inventario.
Variabili di ambiente richieste:
GHE_ORG= # Github Organization (required if --org option is not specified).
GHE_REPO= # Github Repository (required if --repo option is not specified).
Variabili d'ambiente richieste, se si utilizzaGitHub:
GHE_TOKEN= # Github Enterprise API Token(Optional if you are using --git-token-path)
Opzioni per Git:
--git-token-path #(Optional) Github Token's path
--git-api-url #(Optional) Github API url
| Opzione | Descrizione | Tipo di valore | Obbligatoria o facoltativa | Valore/i possibile/i / Valore predefinito / Osservazioni |
|---|---|---|---|---|
| nome | Il nome dell'applicazione a cui appartiene la risorsa utente | Stringa | Obbligatorio |
|
| org | L'organizzazione GitHub che possiede il repository di inventario. | Stringa | Opzionale se è impostata la variabile d'ambiente GHE_ORG |
|
| repo | Il nome del repository dell'inventario. | Stringa | Opzionale se è impostata la variabile d'ambiente GHE_REPO |
|
| ambiente | Il nome dell'ambiente in cui viene aggiunta la voce. | Stringa | Facoltativo | Valore predefinito: "master" |
| git-provider | Il provider del servizio di controllo versione Git. | Stringa | Facoltativo | Predefinito: "github" Valori possibili: ["github", "gitlab"] |
| percorso - token - git | Percorso token Git da cui leggere il segreto | Stringa | Opzionale se è impostata la variabile d'ambiente GHE_TOKEN | Esempio: path/to/git-token |
| url - api - git | URL API Git | Stringa | Facoltativo | Predefinito : " https://<region>.git.cloud.ibm.com/api/v4 |
| ubicazione | Posizione dell'artefatto in altri registri, insieme all'indirizzo sha256 | Stringa | Facoltativo | Esempio: <environment>#<static_name>:<version>@sha256:<sha256_digest>. È possibile specificare questa opzione più volte. |
Esecuzione del comando:
$ cocoa inventory update-locations \
--name=hello-compliance-app \
--git-token-path=./git-token \
--org=test-org \
--repo=compliance-inventory-repo \
--location=stage#stage-us.icr.io/namespace/hello-compliance-app:20201217081811-master-b85e3d472e9cc35b429c39e8c3f9eb282738c20a@sha256:da36831d5154307ac9ca4b8d900df2da0c6c14754977c32479dc62994b5722d0 \
--location=prod#prod-us.icr.io/namespace/hello-compliance-app:20201217081811-master-b85e3d472e9cc35b429c39e8c3f9eb282738c20a@sha256:da36831d5154307ac9ca4b8d900df2da0c6c14754977c32479dc62994b5722d0
comandi di incidente cacao
processo di incidente di cacao
Questo comando elabora i risultati della scansione forniti e crea segnalazioni di incidenti nel repository fornito per ogni vulnerabilità. Se esistono già problemi per le coppie soggetto - incidente, non ne crea di nuovi.
Se --set-grace-period è impostato, crea problemi con il periodo di dilazione impostato o aggiorna i problemi esistenti per avere il periodo di dilazione.
Il periodo di tolleranza è impostato su 15 giorni se abilitato. Se l'esenzione o il periodo di tolleranza è impostato su un problema di incidente, il controllo elenca il problema, ma non lo contrassegna come errore.
Le eccezioni sono configurate in CR VA oppure è possibile inoltrare l'incidente o il CVE per un'approvazione dell'esenzione. Se approvato, è possibile modificare il problema dell'incidente (impostazione Excempt: **true**) e collegarsi
alla richiesta approvata.
File dei risultati della ricerca attualmente supportati:
- Container Registry scansione VA (opzione
--type va) - CRA Vulnerability Scan (opzione
--type cra) - Scansione CRA CIS (opzione
--type cra-cis) - Xray (opzione
--type xray) - OWASP ZAP (opzione
--type owasp-zap) - OWASP ZAP UI (opzione
--type owasp-zap-ui) - Twistlock (opzione
--type twistlock) - Scansioni effettuate da Container Image Multi-Scanner (CIMS) (opzione
--type cims) - Scansione revisione peer (opzione
--type peer-review) - GoLang Security Scan (opzione
--type gosec) - SonarQube Scan (opzione
--type sonarqube) - Mend Scan (opzione
--type mend) - Ripristina scansione SAST (opzione
--type mend-sast) - Checkov (opzione
--type checkov) - Scansione della vulnerabilità PRA per Terraform (opzione
--type cra-tf) - Terraform Security Scan (opzione
--type tfsec) - Fips Scanner (opzione
--type fips-scanner) - Rileva segreti (opzione
--type detect-secrets) - Sysdig (opzione
--type sysdig) - CycloneDX (opzione
--type cyclonedx) - Grype (opzione
--type grype)
Per ulteriori informazioni su Container Registry VA e sul formato dei risultati, vedere Vulnerability Advisor per IBM Cloud Container Registry. Per ulteriori informazioni sullo scanner di vulnerabilità CRA, consultare la documentazione Configuring Code Risk Analyzer.
Uso:
$ cocoa incident process \
<options> \
<path to result file>
Opzioni:
--type # (Required) Scan type [choices: "cra", "va", "xray", "peer-review", "gosec","owasp-zap", "owasp-zap-ui", "sonarqube", "twistlock", "cims", "mend","mend-sast", "checkov", "cra-tf", "tfsec", "fips-scanner", "contrast-sast","detect-secrets", "sysdig", "cyclonedx", "grype", "cra-cis"]
--subject # (Required) Subject of scans (repo, or image name)
--drilldown-url # (Required) URL to the point where the incident was found (can be a pipeline run, a commit hash or an image URL with digest)
--set-grace-period # Should the created incidents have Grace period set
--git-provider # Git service provider [github] Default is "github"
--org # The incident issue repository org
--repo # The incident issue repository name
--label # Label(s) to add to the incident issue (optional) e.g: --label=foo --label=bar
--assignee #(Optional) Assignee(s) for the incident issue (github username) e.g: --assignee=jane-doe --assignee=john-smith
--git-token-path #(Optional) Github Token's path
--git-api-url #(Optional) Github API url
--custom-exempt-label # (Optional) Defines the custom label with which the incident issue has been marked as exempted
--custom-comment # (Optional) Additional text to be added to issue comments
--format # (Optional) Format of the output ("list", "json", default: "list")
Variabili di ambiente richieste:
INCIDENT_REPO_ORG= # Can be used instead of --org (either the option or the variable is required)
INCIDENT_REPO_NAME= # Can be used instead of --repo (either the option or the variable is required)
Variabili d'ambiente richieste, se si utilizzaGitHub:
GHE_TOKEN= # Github Enterprise API Token (Optional if you are using --git-token-path)
Se si usa github, usare il campo --git-token-path per impostare il token GitHub e il campo --git-api-url per impostare l' URL dell'API GitHub Enterprise, invece delle variabili d'ambiente GHE_TOKEN e GH_URL. Se vengono fornite entrambe, --git-token-path e --git-api-url hanno la precedenza.
Valori di ritorno:
- Se non viene trovato alcun problema o se per tutti i problemi rilevati è impostato il periodo di esenzione o di tolleranza, il comando termina con uno stato zero.
- Se per uno dei problemi rilevati non è impostato alcun periodo di tolleranza o di esenzione, il comando termina con uno stato diverso da zero.
- Se il formato è == list - Il comando elenca gli URL dei problemi degli incidenti trovati o creati in base al file dei risultati e all'oggetto.
- Se il formato è == json - Il comando stampa un JSON contenente un array di oggetti di ricerca (ulteriori informazioni sul problema) per ciascuno dei problemi trovati, creati e chiusi automaticamente in base al file dei risultati e all'oggetto.
- Struttura dell'oggetto JSON delle ricerche corrispondente a un problema:
{
"id": string,
"due_date": string,
"severity": ("high", "medium", "low", "critical, "informational"),
"first_found": "string" (optional),
"url": string,
"found_status": ("new", "existing", "autoclosed", "readonly"),
"has_exempt": boolean
}
Esecuzione del comando:
$ cocoa incident process \
--type va \
--subject us.icr.io/service-image \
--drilldown-url us.icr.io/service-image@sha256:digest \
path/to/scan-result.json
processo di incidente del cacao - eredità
Questo comando crea dei problemi nel repository fornito per gli scenari quando un file di scansione non è disponibile. In genere, tali scenari potrebbero essere errori non correlati alla vulnerabilità come errore di test dell'unità, errore
di protezione del ramo, errore di test di accettazione e errore di firma dell'immagine. Questi fallimenti sarebbero non - vulnerabilità, ma sarebbero una deviazione dalla postura di conformità. Se esistono già problemi per le combinazioni
incident - subject - tool, il comando non ne crea di nuovi. Per impostazione predefinita, la valutazione della severità high viene impostata sui problemi creati.
Se --set-due-date è impostato, il comando crea problemi o aggiorna i problemi esistenti con le date di scadenza. Le date di scadenza vengono calcolate dal periodo di dilazione del problema, in base alla gravità.
Se è impostato l'indicatore --close-resolved-issues, il comando ricerca i problemi aperti con lo stesso strumento, oggetto e ID incidente dell'esecuzione corrente. Se vengono rilevati dei problemi, mentre --current-status è stato passato come success, il comando chiude tali problemi.
Se --read-only è impostato, il comando non crea nuovi problemi o modifica quelli esistenti. I risultati vengono elaborati e i problemi esistenti vengono raccolti per i risultati. L'output contiene l'elenco degli URL dei problemi
che dovrebbero essere tracciati nei problemi se la modalità di sola lettura non è attivata.
Uso:
cocoa incident process-legacy \
<options>
Opzioni:
--type # (Required) Tool type
--subject # (Required) Subject of scans (repo, or image name)
--drilldown-url # (Required) URL to the point where the incident was found (can be a pipeline run, a commit hash or an image URL with digest)
--set-grace-period # Should the created incidents have Grace period set
--git-provider # Git service provider [github] Default is "github"
--org # The incident issue repository org
--repo # The incident issue repository name
--label # Label(s) to add to the incident issue (optional) e.g: --label=foo --label=bar
--assignee #(Optional) Assignee(s) for the incident issue (github username) e.g: --assignee=jane-doe --assignee=john-smith
--git-token-path #(Optional) Github Token's path
--git-api-url #(Optional) Github API url
--close-resolved-issues # (Optional) Checking and closing resolved issues
--pipeline-run-url # (Optional) The url to the pipeline run running the CLI command
--is-prod # (Optional) Flag for whether or not the command was run in production environment. Default is false.
--read-only # (Optional) Process result file in read-only mode (return found and existing issues, do not create new ones, set processed status to failure or success). Default is false
--custom-exempt-label # (Optional) Defines the custom label with which the incident has been marked as exempted
--incident-id # (Required) Defines the incident ID to be used for creating legacy incident
--current-status # (Required) Current status to be treated as success or failure [choices: "success", "failure"]
--custom-comment # (Optional) Additional text to be added to issue comments
--format # (Optional) Format of the output ("list", "json", default: "list")
--additional-comment # (Optional) Additional comment for the issue on every run
Variabili di ambiente:
INCIDENT_REPO_ORG= # Can be used instead of --org (either the option or the variable is required)
INCIDENT_REPO_NAME= # Can be used instead of --repo (either the option or the variable is required)
# Required Environment Variables, if using GitHub:
GHE_TOKEN= # Github Enterprise API Token (Optional if using --git-token-path)
Se si usa github, si può usare il campo --git-token-path per impostare il token di GitHub e il campo --git-api-url per impostare l' URL dell'API GitHub Enterprise (per impostazione predefinita https://<region>.git.cloud.ibm.com/api/v4 ), invece delle variabili d'ambiente GHE_TOKEN e GH_URL. Se vengono fornite entrambe le coppie GHE_TOKEN GH_URL e --git-token-path --git-api-url, --git-token-path e --git-api-url hanno la precedenza.
Valori di ritorno:
- Il comando elenca gli URL dei problemi rilevati o creati se
--current-statusè stato passato comefailure. Il comando chiude anche gli URL di problemi dell'incidente che corrispondono alla stessa combinazione incidente - strumento - oggetto se--current-statusè stato passato comefailure. - In modalità
--read-onlyil comando elenca i dettagli degli incidenti trovati se non viene rilevato alcun problema per tale incidente. - Se non sono stati trovati problemi o se tutti i problemi trovati hanno un'etichetta esente impostata, il comando termina con uno stato zero.
- Se uno dei problemi rilevati non ha un'etichetta esente impostata, il comando termina con uno stato diverso da zero.
- In modalità
--read-onlyse viene rilevato un nuovo incidente che non ha alcun problema, il comando termina con uno stato diverso da zero. - Se il formato è == list - Il comando elenca gli URL di problema dell'incidente trovati o creati se
--current-statusè stato passato comefailure. - Se il formato è == json - Il comando stampa un JSON contenente un array di oggetti di ricerca (ulteriori informazioni sul problema) per ciascuno dei problemi trovati, creati e chiusi automaticamente in base al file dei risultati e all'oggetto.
- Struttura dell'oggetto JSON delle ricerche corrispondente a un problema:
{
"id": string,
"due_date": string,
"severity": ("high", "medium", "low", "critical, "informational"),
"first_found": "string" (optional),
"url": string,
"found_status": ("new", "existing", "autoclosed", "readonly"),
"has_exempt": boolean
}
Esecuzione del comando:
$ cocoa incident process-legacy \
--type jest \
--subject us.icr.io/service-image \
--drilldown-url us.icr.io/service-image@sha256:digest \
--incident-id com.ibm.unit_tests_master \
--current-status success \
--close-resolved-issues
valutazione dell'incidente di cacao
Valutare lo stato dei problemi in base a due_date ed esentare l'etichetta ed emettere i risultati dei problemi.
Uso:
$ cocoa incident evaluate \
<options> \
<filePath>
Opzioni:
--git-provider # Git service provider [github] Default is "github"
--org # The incident issue repository org
--repo # The incident issue repository name
--filePath # Path to the JSON file that contains issues to be evaluated
--git-token-path # (Optional) Github Token's path
--git-api-url # (Optional) Github API url
--custom-exempt-label # (Optional) Defines the custom label with which the incident issue has been marked as exempted
--is-prod # (Optional) Whether or not the command was run in prod environment
--format # (Optional) Format of the output ("list", "json", default: "list")
Variabili di ambiente richieste:
INCIDENT_REPO_ORG= # Can be used instead of --org (either the option or the variable is required)
INCIDENT_REPO_NAME= # Can be used instead of --repo (either the option or the variable is required)
Variabili d'ambiente richieste, se si utilizzaGitHub:
GHE_TOKEN= # Github Enterprise API Token (Optional if you are using --git-token-path)
Se si usa github, usare il campo --git-token-path per impostare il token GitHub e il campo --git-api-url per impostare l' URL dell'API GitHub Enterprise, invece delle variabili d'ambiente GHE_TOKEN e GH_URL. Se vengono fornite entrambe, --git-token-path e --git-api-url hanno la precedenza.
Valori di ritorno:
- Se per tutti i problemi rilevati è impostato il periodo di esenzione o di dilazione, il comando termina con lo stato zero.
- Se per uno dei problemi rilevati non è impostato alcun periodo di tolleranza o di esenzione, il comando termina con uno stato diverso da zero.
- Array JSON di ricerche.
- Struttura dell'oggetto JSON delle ricerche corrispondente a un problema.
json
{
"id": string,
"due_date": string,
"severity": ("high", "medium", "low", "critical, "informational"),
"first_found": "string" (optional),
"url": string,
"found_status": ("new", "existing", "autoclosed", "readonly"),
"has_exempt": boolean
}
Esecuzione del comando:
$ cocoa incident evaluate \
--org \
--repo \
--git-provider \
--git-token-path \
--filePath
stato di aggiornamento dell'incidente del cacao
Aggiorna lo stato del problema dell'incidente a open o close in base allo stato attuale dell' URL del problema dell'incidente specificato.
Frammento di codice:
$ cocoa incident update-state \
<options>
Opzioni:
Specificare le seguenti variabili e valori opzionali per fornire ulteriori dettagli sul problema dell'incidente cooca.
--org # The incident issue repo org
--repo # The incident issue repo name
--git-provider # Git service provider [github, gitlab] Default is "github"
--git-token-path # (Optional) Github Token's path
--git-api-url # (Optional) Github API url
--issue-url # Issue URL whose state is to be updated
--to-state # target state for the issue to be updated [choices: "open", "close"]
--comment # (Optional) Comment to be added to the issue being updated
--update-exempt # (Optional) Flag to update state of exempted issues, default: false
Variabili di ambiente richieste:
È necessario fornire le seguenti variabili d'ambiente e i loro valori se non si sono usate le variabili opzionali --org e --repo in precedenza.
INCIDENT_REPO_ORG= # Must be used if --org optional variable is not used.
INCIDENT_REPO_NAME= # Must be used if ---repo optional variable is not used.
Se il vostro git-provider è github, utilizzate la seguente variabile d'ambiente necessaria:
GHE_TOKEN= # Github Enterprise API Token (Optional if you are using --git-token-path)
GH_URL= # Github API url (Optional if you are using --git-api-url)
È inoltre possibile utilizzare le variabili opzionali --git-token-path e --git-api-url per fornire il percorso del token di Github e i valori dell'API URL. Le variabili opzionali hanno una maggiore precendenza quando
sono fornite entrambe, --git-token-path e --git-api-url hanno la precedenza.
Valori di ritorno:
- Il comando esce con il codice di ritorno
0se l'aggiornamento dello stato del problema ha successo. - Il comando esce con il codice di ritorno
1se l'aggiornamento dello stato del problema non ha successo.
Esecuzione del comando:
$ cocoa incident update-state \
--org \
--repo \
--git-provider \
--git-token-path \
--git-api-url \
--issue-url \
--comment \
--to-state
comandi di cacao locker
Caricare prove e allegati su Cloud Object Storage anche a scopo di archiviazione. Viene eseguito automaticamente quando sono presenti le seguenti variabili di ambiente:
COS_ENDPOINT: l'endpointin cui è possibile accedere al bucket Cloud Object Storage.COS_BUCKET_NAME: il nome del bucket Cloud Object Storage.COS_API_KEY: una IBM Cloudo una chiave API ID servizioche ha accesso in scrittura al bucket Cloud Object Storage.BACKUP_COS_ENDPOINT: l'endpointin cui è possibile accedere al bucket Cloud Object Storage.BACKUP_COS_BUCKET_NAME: Il nome della benna dell' BackupCloud Object Storage.BACKUP_COS_API_KEY: Una chiave API di accesso all' IBM Cloud o o una chiave API di accesso all'ID di servizio che ha accesso in lettura al bucket dell' Cloud Object Storage.IBM_AUTH_ENDPOINT: l'endpoint in cui la chiave API può essere utilizzata per generare un token IAM(il valore predefinito èhttps://iam.cloud.ibm.com/identity/token){: external}.
aggiunta asset locker cacao < URI>
Aggiunge un asset al locker delle prove. Visualizza le informazioni sull'asset se l'asset specificato esiste.
Opzioni:
--type # Type of the asset ( All types are supported )
--version # Show version number
--format # Output format ("id", "json", default: "id")
--related # The ID of a related asset (default: [])
--date # Asset creation date
--details # Additional asset details, as key=value pairs (default: [])
--origin # Additional details about the origin of the asset, as key=value pairs (default: [])
--dry-run # Shows what would be added to the locker (default: false)
Utilizzare l'indicatore --dry-run se non si desidera aggiungere nulla all'armadietto e si desidera controllare cosa sarebbe aggiunto all'armadietto.
Il tipo di asset può essere specificato con il flag --type.
Il parametro uri può essere qualsiasi URIvalido, ma alcuni formati vengono trattati in modo particolare:
- Se lo schema
urièdocker(ovvero, inizia condocker://), il comando assume l'indicatore--type=image - Nel caso in cui lo schema
urisiagit, o il percorso termini con un suffisso.git, il comando assume l'indicatore--type=commit
Quando type è image o commit, l'URI deve corrispondere ai seguenti pattern:
- Per
image, l'URI deve contenere il digest dell'immagine (ad esempiodocker://us.icr.io/foo/bar:v1.2.3@sha256:0000000011111111222222223333333344444444555555556666666677777777)
Quando type è diverso da image o commit, l'indicatore --type deve essere passato esplicitamente.
Ulteriori dettagli possono essere aggiunti all'asset utilizzando l'indicatore --details, che accetta coppie key=value.
Ulteriori dettagli sull'origine dell'asset possono essere forniti utilizzando l'indicatore --origin, che accetta le coppie key=value.
Alcune variabili di ambiente vengono selezionate automaticamente per aggiungere dettagli sull'origine dell'asset:
- L'impostazione
TOOLCHAIN_CRNè uguale alla specifica di--origin toolchain_crn=$TOOLCHAIN_CRN - L'impostazione
PIPELINE_IDè uguale alla specifica di--origin pipeline_id=$PIPELINE_ID - L'impostazione
PIPELINE_RUN_IDè uguale alla specifica di--origin pipeline_run_id=$PIPELINE_RUN_ID
L'indicatore --date può essere utilizzato per sovrascrivere la data di creazione dell'asset (il valore predefinito è l'ora corrente), accetta qualsiasi stringa accettata da Date.parse.
Gli asset correlati possono essere aggiunti utilizzando l'indicatore --related (per più asset correlati, l'indicatore può essere specificato più volte). Gli asset possono essere specificati con il loro ID interno o con il relativo
URI. Tutti gli id delle risorse correlate (l'intero albero fino alla prima risorsa) saranno aggiunti al campo parents nel json delle risorse.
Per default, il formato id (indicatore --format ) stampa l'ID interno dell'asset creato. Con il formato json, l'intero asset verrà stampato, come un oggetto JSON.
Esecuzione del comando per aggiungere un commit Git:
$ cocoa locker asset add 'https://github.com/foo/bar.git#aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee' \
--details tag=v1.2.3
Output di esempio:
b5bbbbb55555b5555b555b55b5555bb5b555b5b555bb5b55bbb5555fbbbbb
Esecuzione del comando per aggiungere un'immagine Docker:
$ cocoa locker asset add docker://us.icr.io/foo/bar:v1.2.3@sha256:0000000011111111222222223333333344444444555555556666666677777777 \
--origin "job_name=my job" \
--related https://github.com/foo/bar.git#aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee \
--format json
Output di esempio:
{
"version": "1.1",
"id": "0000000011111111222222223333333344444444555555556666666677777777",
"uri": "docker://us.icr.io/foo/bar:v1.2.3@sha256:0000000011111111222222223333333344444444555555556666666677777777",
"origin": {
"job_name": "my job",
"toolchain_crn": "crn:v1:bluemix:public:toolchain:au-syd:a/111111111111c2f2222222222b22a7a63:ac2a22a2-2a2a-2222-aaa2-222aa22a2a2a::",
"pipeline_run_id": "f333b3bc-3333-3fea-3333-333d3a3b33b3",
"pipeline_id": "444aaa4a-b4c4-4444-4f4b-aa4444a444a4"
},
"details": {
"registry": "us.icr.io",
"name": "foo/bar",
"tag": "v1.2.3",
"digest": "0000000011111111222222223333333344444444555555556666666677777777"
},
"date": "2021-07-15T14:26:06.301Z",
"type": "image",
"related": [
"b5bbbbb55555b5555b555b55b5555bb5b555b5b555bb5b55bbb5555fbbbbb"
],
"parents": [
"b5bbbbb55555b5555b555b55b5555bb5b555b5b555bb5b55bbb5555fbbbbb"
]
}
Esecuzione del comando per l'aggiunta di una release:
$ cocoa locker asset add release:my-app@v1.2.3 \
--type generic \
--date 2021-06-01T12:00:00 \
--related docker://us.icr.io/foo/bar:v1.2.3@sha256:0000000011111111222222223333333344444444555555556666666677777777
Output di esempio:
36d8852458adf44ab236c99beb69d7070d461d39480bc6b8ef7c771bee93cb49%
Ottieni asset locker di cacao < URI>
Richiama un asset dal locker delle prove.
Opzioni:
--type # Type of the asset
--version # Show version number
--format # Output format ("id", "json", default: "id")
Esegui il comando:
cocoa locker asset get release:my-app@v1.2.3 --format json
Output di esempio:
{
"version": "1.1",
"id": "36d8852458adf44ab236c99beb69d7070d461d39480bc6b8ef7c771bee93cb49",
"uri": "release:my-app@v1.2.3",
"origin": {
"toolchain_crn": "crn:v1:bluemix:public:toolchain:au-syd:a/111111111111c2f2222222222b22a7a63:ac2a22a2-2a2a-2222-aaa2-222aa22a2a2a::",
"pipeline_run_id": "f333b3bc-3333-3fea-3333-333d3a3b33b3",
"pipeline_id": "444aaa4a-b4c4-4444-4f4b-aa4444a444a4"
},
"details": {
"sha": "aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee",
"repository": <repository-url>,
"tag": "v1.2.3"
},
"date": "2021-07-15T14:26:06.301Z",
"type": "image",
"related": ["0000000011111111222222223333333344444444555555556666666677777777"],
"parents": ["0000000011111111222222223333333344444444555555556666666677777777", "b5bbbbb55555b5555b555b55b5555bb5b555b5b555bb5b55bbb5555fbbbbb"]
}
cocoa locker asset get docker://us.icr.io/foo/bar:v1.2.3@sha256:0000000011111111222222223333333344444444555555556666666677777777 --format json
Output di esempio:
{
"version": "1.1",
"id": "0000000011111111222222223333333344444444555555556666666677777777",
"uri": "docker://us.icr.io/foo/bar:v1.2.3@sha256:0000000011111111222222223333333344444444555555556666666677777777",
"origin": {
"toolchain_crn": "crn:v1:bluemix:public:toolchain:au-syd:a/111111111111c2f2222222222b22a7a63:ac2a22a2-2a2a-2222-aaa2-222aa22a2a2a::",
"pipeline_run_id": "f333b3bc-3333-3fea-3333-333d3a3b33b3",
"pipeline_id": "444aaa4a-b4c4-4444-4f4b-aa4444a444a4"
},
"details": {
"sha": "aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee",
"repository": <repository-url>,
"tag": "v1.2.3"
},
"date": "2021-07-15T14:26:06.301Z",
"type": "image",
"related": [],
"parents": ["b5bbbbb55555b5555b555b55b5555bb5b555b5b555bb5b55bbb5555fbbbbb"]
}
cocoa locker asset get https://github.com/foo/bar.git#aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee --format json
Output di esempio:
{
"version": "1.1",
"id": "0000000011111111222222223333333344444444555555556666666677777777",
"uri": "docker://us.icr.io/foo/bar:v1.2.3@sha256:0000000011111111222222223333333344444444555555556666666677777777",
"origin": {
"toolchain_crn": "crn:v1:bluemix:public:toolchain:au-syd:a/111111111111c2f2222222222b22a7a63:ac2a22a2-2a2a-2222-aaa2-222aa22a2a2a::",
"pipeline_run_id": "f333b3bc-3333-3fea-3333-333d3a3b33b3",
"pipeline_id": "444aaa4a-b4c4-4444-4f4b-aa4444a444a4"
},
"details": {
"sha": "aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee",
"repository": <repository-url>,
"tag": "v1.2.3"
},
"date": "2021-07-15T14:26:06.301Z",
"type": "image",
"related": [],
"parents": []
}
Riepilogo asset Coa Locker get < URI>
Raccoglie il riepilogo delle prove per l'asset fornito dal locker delle prove.
Opzioni:
--scope # (Required) Pipeline run ID of the CI piepline where the asset is built
--environment # (Required) Name of the environment from which evidences are fetched, if the `service-environment` is `pre_prod`
This value must be the same as the `target-environment`. Or, if `service-environment` is `prod`, then this value must be the same as the `source-environment`
--service-environment # Service environment of the asset get summary in deployed environment
(choices: 'pre_prod', 'dev', 'prod', default: 'pre_prod')
--latest # Fetches the latest evidence summary of the asset for the `service-environment`.
The summary of the scope passed-in using `--scope` will be excluded. Currently supported for `dev` environment only.
Esegui il comando:
cocoa locker asset summary get https://github.com/foo/bar.git#aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee \
--scope 11a1aa11-1a11-11a1-aa11-a11a1a1111a1 \
--environment prod \
--service-environment prod
Eseguire il comando per recuperare il riepilogo delle prove più recente escludendo quello dell'ambito passato utilizzando --scope:
cocoa locker asset summary get https://github.com/foo/bar.git#aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee \
--scope 11a1aa11-1a11-11a1-aa11-a11a1a1111a1 \
--environment dev \
--service-environment dev \
--latest
elenco asset locker di cacao < URI>
Elenca gli asset correlati dal locker delle prove.
Opzioni:
--type # Type of the asset
--version # Show version number
--format # Output format ("id", "json", default: "id")
Esegui il comando:
cocoa locker asset list release:my-app@v1.2.3 --format id --type generic
Output di esempio:
1122211111122222111111111111111111111111111111666661111111111111
2222222222555552222222222222222333333222222222222222222222222222
3333333337777773333333333333333333333333333333344444433333333333
Esecuzione del comando utilizzando il formato json combinato con jq:
cocoa locker asset list release:my-app@v1.2.3 --format json --type generic | jq -r '.[].uri'
Output di esempio:
release:my-app@v1.2.3
docker://us.icr.io/foo/bar:v1.2.3@sha256:0000000011111111222222223333333344444444555555556666666677777777
https://github.com/foo/bar.git#aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee
Aggiungi la prova dell'armadietto del cacao
Aggiunge prove all'armadietto delle prove.
Il locker delle prove può essere specificato utilizzando indicatori. Per ulteriori informazioni, consultare Comandi di cacao locker.
La prova può essere configurata utilizzando i seguenti indicatori:
--evidence-type: una stringa che identifica il tipo di prova (ad esempiocom.ibm.unit_test)--evidence-type-version: una stringa che identifica lo schema dei dettagli della prova (ad esempio,1.0.0,v2e così via)
È possibile specificare anche alcuni indicatori facoltativi:
--date: la data di creazione della prova (il valore predefinito è la data/ora corrente), accetta una stringa che può essere analizzata conDate.parse.--details: i dettagli della prova possono essere specificati come coppie dikey=value, l'indicatore può essere specificato più volte (ad esempio--details result=success --details foo=bare così via).--origin: i dettagli sull'origine della prova possono essere specificati utilizzando le coppiekey=value, ad esempio--origin job_id=123e così via.--asset: specifica quali asset (in base al loro URI o ID interno) sono rilevanti per la prova, consultare i comandicocoa locker asset. L'indicatore può essere specificato più volte. L'asset deve essere già presente nell'armadietto.--attachment: specifica i file allegati alla prova. Ogni allegato deve puntare a un file esistente e ogni nome di allegato deve essere univoco (ovvero,--attachment a/foo.json --attachment b/foo.jsonnon è consentito).--attachment-url: specifica gli URL degli allegati che sono già memorizzati nel locker delle prove. Ogni URL deve puntare a un allegato unico, in modo da non creare duplicati. Questo indicatore può essere specificato più volte per includere più URL.--issue: elenco di URL di problemi, che possono essere utilizzati per tracciare le attività correlate ai risultati. L'indicatore può essere passato più volte.--findings-path: utilizzare questo percorso per passare l'array di ricerche JSON che è l'output del comando di processo Incidente.--scope: un identificativo univoco che può essere utilizzato per correlare le prove da più origini.--comment-on-issues: aggiungere un commento con i dettagli sulla prova creata ai problemi dell'incidente forniti utilizzando l'indicatore--issue- Poiché i problemi possono essere presenti su
github, il provider viene analizzato dagli URL dei problemi - Ogni problema deve provenire dallo stesso repository
- Gli URL del problema devono corrispondere al seguente pattern:
https://<host>/<owner>/<name>/issues/<issue number>- pergithub
- Variabili di ambiente richieste per accedere al repository dei problemi:
- se gli URL puntano a problemi
github:GH_URL: facoltativo, il valore predefinito èhttps://<region>.git.cloud.ibm.com/api/v4GHE_TOKEN
- se gli URL puntano a problemi
- Poiché i problemi possono essere presenti su
Informazioni sull'etichetta per un allegato in evidenza JSON:
Ogni sezione dell'allegato nel JSON delle prove dispone di una proprietà etichetta per contenere i metadati sull'allegato. All'etichetta viene assegnato un valore predefinito e questo valore dipende dal fatto che l'input dell'allegato sia
un percorso file o un URL dell'allegato. Passa un'etichetta personalizzata aggiungendo ::label=<value> alla fine del percorso dell'allegato o dell'URL dell'allegato.
Esempi:
-
--attachment path/to/attachment::label=label_name- Crea un allegato utilizzando il file inpath/to/attachmente imposta il valore dell'etichetta sulabel_name. Se l'etichetta non viene passata, il nome del file viene utilizzato come valore dell'etichetta per impostazione predefinita. -
--attachment-url url/of/attachment::label=label_name- Utilizza l'allegato specificato nel fileattachment-urle imposta il valore dell'etichetta sulabel_name. Se l'etichetta non viene passata, per impostazione predefinita il valore dell'etichetta è una stringa vuota.
Alcune variabili di ambiente vengono selezionate automaticamente per aggiungere dettagli sull'origine dell'asset:
- L'impostazione
TOOLCHAIN_CRNè uguale alla specifica di--origin toolchain_crn=$TOOLCHAIN_CRN - L'impostazione
PIPELINE_IDè uguale alla specifica di--origin pipeline_id=$PIPELINE_ID - L'impostazione
PIPELINE_RUN_IDè uguale alla specifica di--origin pipeline_run_id=$PIPELINE_RUN_ID
Il funzionamento del comando può essere modificato utilizzando questi indicatori:
--dry-run: non aggiunge nulla all'armadietto, ma mostra cosa dovrebbe essere aggiunto.--cache-mode: simile a dry - run. In realtà non aggiunge le prove all'armadietto, ma aggiunge gli allegati (se presenti) all'armadietto. Mostra la prova che verrà aggiunta.--format: controlla il formato di output,idojson(idper impostazione predefinita).
Eseguire il comando per salvare i risultati per detect-secrets:
$ cocoa locker evidence add --evidence-type com.ibm.detect_secrets \
--evidence-type-version 1.0.0 \
--details result=success \
--asset https://github.com/foo/bar.git#aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee
Eseguire il comando per salvare i risultati del controllo unità:
$ cocoa locker evidence add --evidence-type com.ibm.unit_test \
--evidence-type-version 1.0.0 \
--details failure \
--asset https://github.com/foo/bar.git#aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee
--attachment path/to/results/junit.xml \
--issue <issue-link> \
--findings-path <path/to/file>
Eseguire il comando per creare una nuova prova utilizzando un allegato già esistente nel blocco di prove:
$ cocoa locker evidence add --evidence-type com.ibm.detect_secrets \
--evidence-type-version 1.0.0 \
--attachment-url https://github.com/foo/bar/blob/master/raw/attachments/5aa5555aa55aa55a555aa5a5aa555555aaaa5aa5aa5555a55a5aa5aa5a5aaaaa/content
--asset https://github.com/foo/bar.git#aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee
Esegui il comando per salvare i risultati dei test unitari e aggiungere un'etichetta personalizzata all'allegato:
$ cocoa locker evidence add --evidence-type com.ibm.unit_test \
--evidence-type-version 1.0.0 \
--details success \
--asset https://github.com/foo/bar.git#aaaaaaaabbbbbbbbccccccccddddddddeeeeeeee
--issue <issue-link> \
--findings-path <path/to/file> \
--attachment path/to/results/junit.xml::label=unit-test
La prova di cacao locker ottiene < evidence - id>
Richiama una prova dall'armadietto.
Opzioni:
--version # Show version number
--format # Output format ("json", default: "json")
Esegui il comando:
cocoa locker evidence get 0000000011111111222222223333333344444444555555556666666677777777
Output di esempio:
{
"id": "0000000011111111222222223333333344444444555555556666666677777777",
"evidence_type_id": "com.ibm.unit_tests",
"evidence_type_version": "1.0.0",
"date": "2024-03-27T16:36:48.167Z",
"origin": {
"toolchain_crn": "crn:v1:bluemix:public:toolchain:us-south:a/40111714589c4f7099032529b26a7a63:f0ffdc07-616e-40fa-98d5-2f52d5e8ef4d::",
"pipeline_id": "b313626a-a612-4c98-ae5c-408af7d7ce58",
"pipeline_run_id": "cadb83be-f00d-44af-95d0-1b49deb8abb5",
"pipeline_run_url": "https://cloud.ibm.com/devops/pipelines/tekton/b313626a-a612-4c98-ae5c-408af7d7ce58/runs/cadb83be-f00d-44af-95d0-1b49deb8abb5/code-unit-tests/run-stage/?env_id=ibm:yp:us-south",
"scope": "82aef875749c6386381a3baff8430df6f5ac2e8434cc91e5287ce65bd71a3985"
},
"details": {
"result": "pending",
"tool": "jest"
},
"issues": [],
"findings": [],
"attachments": [
{
"hash": "9a841ef856a5de813dbe440b102b9bff3ca1831630292cff7323c557704f386b",
"url": "https://s3.private.us-south.cloud-object-storage.appdomain.cloud/test/assets/9a841ef856a5de813dbe440b102b9bff3ca1831630292cff7323c557704f386b/index.json",
"label": "unit-test"
}
],
"assets": [
{
"hash": "7d930918fbb8be80f3a5100f0313c5b2518eba22cc915194cf971d4daf5170be",
"uri": <git-uri-to-asset>,
"url": "https://s3.us-south.cloud-object-storage.appdomain.cloud/cocoa-development/assets/7d930918fbb8be80f3a5100f0313c5b2518eba22cc915194cf971d4daf5170be/index.json"
}
]
}
riepilogo prove di cacao locker < id - asset>
Restituisce il riepilogo delle prove per uno o più asset. Quando non viene specificato alcun asset sulla riga comandi, gli asset vengono letti da stdin.
Indicatori facoltativi:
--latest-only: scarta la prova se è disponibile una prova più recente per un asset (trueper impostazione predefinita, impostato sufalseper disabilitare questo comportamento)--scope: considera che la prova che ha solo l'ambito specificato (consultareevidence add --scope), può essere specificata più volte--linked-scope: considera l'evidenza che ha come ambito l'ambito collegato specificato. Inoltre, li aggiunge alla proprietà linked-scopes nel riepilogo delle prove restituito. Può essere specificato più volte.--check-immutable-storage: controlla se tutte le prove sono presenti anche in un bucket Cloud Object Storage ed è protetto da un periodo di conservazione di almeno 365 giorni. Accoda la provacom.ibm.immutable_storageal riepilogo.- Consulta la sezione
cocoa lockersu come configurare il bucket Cloud Object Storage.
- Consulta la sezione
--dry-run: ha un effetto se combinato con--check-immutable-storage. Se utilizzato, la provacom.ibm.immutable_storageviene accodata solo al riepilogo ma non viene caricata nel blocco di prove.--clone-dir: Un parametro opzionale per determinare il percorso di clonazione del Repository di Evidence, per impostazione predefinita clonerà la directory del repo /tmp--initialized: Flag opzionale che presuppone che l'armadietto delle prove sia già clonato nella posizione fornita--clone-diro/tmp/.--evidences-path: Per creare un riepilogo dalle prove locali che sono state inserite in una cache, questo campo viene utilizzato per fornire il percorso del file in cui sono presenti tutte le prove nell'array.
Esegui il comando:
$ cocoa locker evidence summary \
docker://us.icr.io/foo/bar@sha256:1234567812345678123456781234567812345678123456781234567812345678 \
docker://us.icr.io/baz/quux@sha256:1234567812345678123456781234567812345678123456781234567812345678 \
--scope 11a1aa11-1a11-11a1-aa11-a11a1a1111a1 \
--scope 22a2aa22-2a22-22a2-aa22-a22a2a2222a2 \
--linked-scope 33a3aa33-3a33-33a3-33a3-a33a3a3333a3 \
--linked-scope 12bqab22-1a23-1a23-1a23-b22a3a2222a3
Esempio letto da stdin:
$ cat <<EOF | cocoa locker evidence summary
docker://us.icr.io/foo/bar@sha256:1234567812345678123456781234567812345678123456781234567812345678
docker://us.icr.io/baz/quux@sha256:1234567812345678123456781234567812345678123456781234567812345678
EOF
L'allegato di cacao locker ottiene < attachment - id>
Richiama un allegato precedentemente caricato con cocoa locker evidence add.
Opzioni:
--version # Show version number
Eseguire il comando per caricare l'allegato:
$ cocoa locker evidence add --evidence-type-id com.ibm.unit_test \
--evidence-type-version 1.0 \
--details result=success \
--attachment path/to/junit.xml::label=unit-test
Output di esempio del caricamento dell'allegato:
{
...
"attachments": [
{
"hash": "9a841ef856a5de813dbe440b102b9bff3ca1831630292cff7323c557704f386b",
"url": "https://s3.private.us-south.cloud-object-storage.appdomain.cloud/test/assets/9a841ef856a5de813dbe440b102b9bff3ca1831630292cff7323c557704f386b/index.json",
"label": "unit-test"
}
],
...
}
Esegui il comando per recuperare l'allegato:
cocoa locker attachment get 5aa5555aa55aa55a555aa5a5aa555555aaaa5aa5aa5555a55a5aa5aa5a5aaaaa
assegno armadietto cacao
Verifica la configurazione e le impostazioni richieste del locker.
Attualmente, solo il locker basato su Cloud Object Storage ha un requisito di configurazione:
- Poiché ogni prova deve essere mantenuta per almeno un anno, il bucket Cloud Object Storage deve essere protetto da una politica di conservazione. Il periodo di conservazione predefinito deve essere maggiore o uguale a 365 giorni.
Per ulteriori informazioni, consultare Comandi di cacao locker.
Variabili di ambiente richieste:
COS_API_KEY= # Cloud Object Storage API Key
COS_BUCKET_NAME= # Bucket Name where the evidence will be uploaded in the COS Instance
COS_ENDPOINT= # The COS API Endpoint matching the region where the bucket is located
Esegui il comando:
cocoa locker check --provider='cos'
controllo delle prove dell'armadietto del cacao
Convalidare la prova richiesta in base alle verifiche presenti nel file di configurazione cocoa locker evidence check.
Variabili di ambiente richieste:
Opzioni:
--org # (Required) Owner of the evidence locker repo, defaults to `EVIDENCE_LOCKER_REPO_OWNER`
--repo # (Required) Name of the evidence locker repo, defaults to `EVIDENCE_LOCKER_REPO_NAME`
--git-provider # Git service provider ("github")
--git-token-path # Git token path to read the secret from
--git-api-url # Github API URL
--config-path # (required) use this path to read the config file of all the required evidence check
--summary-path # (required) use this path to read the summary file of all the evidences
--pre-deployment # If present, will check only pre deployment checks, defaults to false
--post-deployment # If present, will check only post deployment checks, defaults to false
--source # (Applies to config file version 2) If present, is tupple of branch:region information(with region as optional) which will be used to filter the rules against `source_environments` field.
--target # (Applies to config file version 2) If present, is tupple of branch:region information(with region as optional) which will be used to filter the rules against `target_environments` field.
--pipeline-run-id # (Applies to config file version 2) If present, is current pipeline_run_id will be used for checking evidences.
--output-config-path # optional path to create a more suitable file based on the current config file
Esegui il comando:
cocoa locker evidence check --summary-path `<summary-path>` --config-path `<config-path>` --pre-deployment --post-deployment --source `<source_branch:region>` --target `<target_branch:region>` --pipeline-run-id `<current_pipeline-run-id>`
raccolta delle prove dell'armadietto del cacao
Raccogliere le prove e conservarle nell'armadietto. Questo comando è l'implementazione sottostante per lo script di shell collect-evidence.
Utilizzo
cocoa locker evidence collect [OPTIONS]
Parametri obbligatori
-
--tool-type <string>Identificatore dello strumento (ad esempio, "sonarqube", "cra", "owasp-zap", "detect-secrets") -
--evidence-type <string>Tipo di prova (ad esempio, " com.ibm.static_scan ", " com.ibm.unit_tests ", " com.ibm.detect_secrets ") -
--assets <key:type>Specifiche delle attività nel formato "key:type". Può essere specificato più volte per più asset. Esempio:--assets app-repo:repoo--assets my-image:artifact -
--status <string>Stato delle prove:success|failure|pending -
--pipeline-run-id <string>Identificatore della corsa della pipeline -
--pipeline-namespace <string>Spazio dei nomi della pipeline:pr|ci|cd|cc -
--incident-org <string>Git organizzazione per il deposito degli incidenti -
--incident-repo <string>Nome del deposito dell'incidente
Parametri richiesti per la piattaforma tekton.
-
--pipeline-id <string>Identificatore della conduttura -
--task-name <string>Nome del task all'interno della pipeline -
--step-name <string>Nome del passo all'interno dell'attività
Parametri facoltativi
-
--attachment <path>File allegati come i risultati delle scansioni (possono essere specificati più volte) -
--attachment-url <url>URL degli allegati precaricati (può essere specificato più volte) -
--meta <key=value>Coppie di metadati chiave=valore (possono essere specificate più volte) -
--additional-comment <string>Commento aggiuntivo da includere nelle questioni relative agli incidenti -
--show-tableVisualizzare i dettagli delle prove in formato tabellare -
--dry-runAnteprima senza salvare nell'armadietto -
--cache-modeAggiungete solo gli allegati, saltate la prova stessa -
--evidence-reuseAbilita la funzione di riutilizzo delle prove -
--evidence-per-assetCreare prove per ogni asset separatamente -
--upload-logs <boolean>Carica i log come allegati se non vengono forniti altri allegati (valore predefinito: true) -
--incident-git-provider <string>Git fornitore:github|gitlab(impostazione predefinita: github) -
--incident-git-token-path <path>Percorso del token Git per l'autenticazione -
--incident-git-api-url <url>Base API personalizzata Git URL -
--incident-labels <string>Etichette da applicare ai problemi degli incidenti (possono essere specificate più volte) -
--incident-assignees <string>GitHub/GitLab nomi utente da assegnare agli incidenti (possono essere specificati più volte) -
--comment-on-issuesCollegare le prove aggiunte alle questioni relative agli incidenti -
--pr-issue-managementAbilitare il collegamento e la gestione delle richieste di pull e dei problemi -
--opt-in-auto-closeConsentire la chiusura automatica degli incidenti se risolti -
--custom-exempt-label <string>Etichetta che indica l'esenzione dai requisiti di conformità -
--platform <string>Piattaforma utilizzata per recuperare i log:tekton|github-actions(default: tekton) -
--root-pipeline-run-id <string>Identificatore dell'esecuzione della pipeline principale -
--toolchain-crn <string>Nome della risorsa cloud (CRN) della catena di strumenti -
--deployment-prefix <string>Il prefisso di distribuzione -
--target-environment <string>Ambiente di destinazione (predefinito: prod) -
--target-environment-purpose <string>Scopo dell'ambiente target -
--collect-evidence-in-pr <string>Raccogliere prove in un contesto di PR:none|success|all -
--pr-html-url <string>URL alla richiesta di pull associata -
--base-branch <string>Ramo di base per la richiesta di pull -
--branch <string>Nome ramo -
--gh-org <string>GitHub organizzazione in cui viene eseguita la pipeline (specifica per la piattaforma di azioni github). -
--gh-repo <string>GitHub repository in cui viene eseguita la pipeline (specifico per la piattaforma di azioni github). -
--gh-server-url <string>GitHub Azioni: Server URL (specifico per la piattaforma di azioni github). -
--gh-repository-url <string>GitHub Azioni: Repository completo URL (specifico per la piattaforma di azioni github). -
--gh-run-attempt <string>GitHub Azioni: Numero di tentativi di esecuzione del flusso di lavoro (specifico per la piattaforma di azioni github). -
--run-id <string>Esegui identificativo -
--xforce-api-key <string>Chiave API per IBM X-Force Exchange -
--xforce-password <string>Password API per IBM X-Force Exchange -
--xforce-url <string>IBM X-Force Exchange API URL
Esempio
cocoa locker evidence collect \
--tool-type "sonarqube" \
--evidence-type "com.ibm.static_scan" \
--assets "app-repo:repo" \
--status "success" \
--attachment ./sonarqube-result.json \
--pipeline-run-id "abc123" \
--pipeline-namespace "ci" \
--incident-org "my-org" \
--incident-repo "compliance-issues" \
--meta "environment=staging"
riutilizzo delle prove dell'armadietto del cacao
Trovare e riutilizzare le prove esistenti per un determinato bene. Questo comando è l'implementazione sottostante per lo script di shell check-evidence-for-reuse.
Utilizzo
cocoa locker evidence reuse [OPTIONS]
Parametri obbligatori
-
--tool-type <string>Identificatore dello strumento (ad esempio, "sonarqube", "cra", "owasp-zap") -
--evidence-type <string>Tipo di prova (ad esempio, " com.ibm.static_scan ", " com.ibm.unit_tests ") -
--assets <key:type>Specifiche delle risorse nel formato "chiave:tipo" -
--pipeline-run-id <string>Identificatore della corsa della pipeline -
--pipeline-namespace <string>Spazio dei nomi della pipeline:pr|ci -
--incident-org <string>Git organizzazione per il deposito degli incidenti -
--incident-repo <string>Nome del deposito dell'incidente
Parametri richiesti per la piattaforma tekton.
-
--task-name <string>Nome del task all'interno della pipeline -
--step-name <string>Nome del passo all'interno del task -
--pipeline-id <string>Identificatore della conduttura
Parametri facoltativi
-
--meta <key=value>Metadati per la convalida rispetto alle prove trovate per il riutilizzo (possono essere specificati più volte) -
--evidence-validity-period <number>Periodo di validità in ore (default: 24, max: 720 ore / 30 giorni) -
--evidence-reuse-for-failureAbilita il riutilizzo delle prove fallite (default: false) -
--dry-runModalità di anteprima senza riutilizzare le prove -
--show-tableVisualizzare i dettagli delle prove in formato tabellare -
--format <string>Formato di uscita:json(predefinito: json) -
--incident-git-provider <string>Git fornitore:github|gitlab(impostazione predefinita: github) -
--incident-git-token-path <path>Percorso del token Git per l'autenticazione -
--incident-git-api-url <url>Base API personalizzata Git URL -
--incident-assignees <string>GitHub/GitLab nomi utente da assegnare agli incidenti (possono essere specificati più volte) -
--custom-exempt-label <string>Etichetta che indica l'esenzione dai requisiti di conformità -
--deployment-prefix <string>Il prefisso di distribuzione -
--root-pipeline-run-id <string>Identificatore dell'esecuzione della pipeline principale -
--toolchain-crn <string>Nome della risorsa cloud (CRN) della catena di strumenti -
--platform <string>Piattaforma utilizzata per recuperare i log:tekton|github-actions(default: tekton) -
--gh-org <string>GitHub organizzazione in cui viene eseguita la pipeline (specifica per la piattaforma di azioni github) -
--gh-repo <string>GitHub repository in cui viene eseguita la pipeline (specifico per la piattaforma di azioni github) -
--run-id <string>Esegui identificativo -
--environment <string>Ambiente (predefinito: dev) -
--serviceEnvironment <string>Ambiente di servizio (predefinito: dev)
Esempio
Utilizzo di base:
cocoa locker evidence reuse \
--tool-type "sonarqube" \
--evidence-type "com.ibm.static_scan" \
--assets "app-repo:repo" \
--pipeline-run-id "abc123" \
--pipeline-namespace "ci" \
--incident-org "my-org" \
--incident-repo "compliance-issues" \
--format "json"
Con periodo di validità personalizzato e convalida dei metadati:
cocoa locker evidence reuse \
--tool-type "cra" \
--evidence-type "com.ibm.code_vulnerability_scan" \
--assets "app-repo:repo" \
--pipeline-run-id "xyz789" \
--pipeline-namespace "ci" \
--incident-org "my-org" \
--incident-repo "compliance-issues" \
--evidence-validity-period 48 \
--meta "tool-version=1.2.3" \
--meta "base-image=ubuntu:22.04" \
--format "json"
Riutilizzare le prove fallite:
cocoa locker evidence reuse \
--tool-type "owasp-zap" \
--evidence-type "com.ibm.dynamic_scan" \
--assets "my-app:artifact" \
--pipeline-run-id "xxx-001" \
--pipeline-namespace "cd" \
--incident-org "my-org" \
--incident-repo "compliance-issues" \
--evidence-reuse-for-failure \
--format "json"
Codice uscita
0: Prove trovate e riutilizzate con successo1: Non sono state trovate prove riutilizzabili o la convalida non è riuscita
comandi di cacao tekton
Cacao tekton get - pipeline - log
Crea i file di log per ogni passo da un'esecuzione della pipeline e li salva in una directory. Utilizzare le variabili di ambiente (PIPELINE_ID, PIPELINE_RUN_ID) o sovrascrivere le variabili di ambiente con indicatori
espliciti (--pipeline-id, --pipeline-run-id). I file di log possono essere richiamati anche a livello per attività e per fase fornendo indicatori --task-name e --step-name.
Se viene fornito --task-name, il comando tenta di eseguire il pull e crea i file di log per ogni passo per il nome dell'attività fornito.
Se --step-name viene fornito insieme a --task-name, il comando crea il file di log per il passo specifico per il task-name. --step-name fornito senza --task-name è una firma
del comando non valida.
Opzioni:
-o --output-dir # (Required) Specifies the directory where the logs will be saved
--pipeline-id # ID of the pipeline
--pipeline-run-id # ID of the pipeline run
-u --use-task-ref # (Optional) Can be used to override the default name of the pipeline task to the taskRef, when creating the directory
--task-name # (Optional) use task-name to fetch the logs for --task-name
--step-name # (Optional) use step-name in conjunction with task-name to fetch the log for --step-name
Variabili di ambiente richieste:
IBMCLOUD_API_KEY= # IBM Cloud API Token
TOOLCHAIN_REGION= # Region of the toolchain
PIPELINE_ID= # Can be used instead of '--pipeline-id option
PIPELINE_RUN_ID= # Can be used instead of '--pipeline-run-id option
Esecuzione del comando:
$ cocoa tekton get-pipeline-logs \
--output-dir=<output-dir> \
--pipeline-id=<pipeline-id> \
--pipeline-run-id=<pipeline-run-id> \
--use-task-ref
comandi di commento cacao
Commento cacao aggiungi
Aggiunge un commento a un problema o a una richiesta di pull in GitHub.
Opzioni:
--content # (Required) The content to be added as comment to issue or pr
--id # (Required) The issue number or pull request number
--type # (Optional) The type (issue or pr), default is issue
--org # The git repo org
--repo # The git repo name
--git-provider # (Optional) Git service provider [github]
--git-token-path # (Optional) Github Token's path
--git-api-url # (Optional) Github API URL
Variabili di ambiente richieste:
GHE_ORG= # Can be used instead of --org (either the option or the variable is required)
GHE_REPO= # Can be used instead of --repo (either the option or the variable is required)
Variabili di ambiente obbligatorie, se si utilizzaGitHub:
GHE_TOKEN= # Github Enterprise API Token (Optional if you are using --git-token-path)
Se si usa github, usare il campo --git-token-path per impostare il token GitHub e usare il campo --git-api-url per impostare l' URL dell'API GitHub Enterprise, invece delle variabili d'ambiente GHE_TOKEN e GH_URL. Se vengono fornite sia le proprietà dell'ambiente che i parametri della riga comandi, --git-token-path e --git-api-url hanno la precedenza.
Esecuzione del comando:
$ cocoa comment add --id 1 \
--content "This is a test comment" \
--type pr \
--git-provider github \
--org <github-organization> \
--repo <github-repo-name>
comandi per le etichette di cacao
aggiunta di un'etichetta di cacao
Aggiunge una o più etichette alle richieste di pull in GitHub o GitLab.
Opzioni:
--label # (Required) The label to be added to the pull request. This command be specified multiple times.
--id # (Required) The pull request number. Can be specified multiple times.
--type # (Optional)The type of the item (issue or PR). The default type is PR.
--org # The Git repository organization.
--repo # The Git repository name.
--git-provider # (Optional) The Git service provider. The default git provider is Github.
--git-token-path # (Optional) The path to the Git token.
--git-api-url # (Optional) The URL of the Git API.
Variabili di ambiente richieste:
GHE_ORG= # The Git repository organization. Can be used instead of the --org option. Either the option or the variable is required.
GHE_REPO= # The Git repository name. Can be used instead of the --repo option. Either the option or the variable is required.
Variabili d'ambiente necessarie per GitHub:
GHE_TOKEN= # Github Enterprise API Token (Optional if you are using --git-token-path)
Se si utilizza GitHub, è necessaria la seguente variabile d'ambiente:
| Variabile | Descrizione |
|---|---|
GHE_TOKEN |
Il token API GitHub Enterprise. Opzionale se si utilizza l'opzione --git-token-path. |
Opzioni della riga di comando:
In alternativa, è possibile utilizzare le seguenti opzioni della riga di comando per effettuare l'autenticazione:
| Opzioni della riga di comando | Descrizione |
|---|---|
--git-token-path |
Impostare il token GitHub. |
--git-api-url |
Impostare l' URL dell'API GitHub Enterprise. |
Se vengono fornite sia proprietà dell'ambiente che parametri della riga di comando, le opzioni --git-token-pat h e --git-api-url hanno la precedenza.
Esempio: Aggiunta di un'etichetta a una richiesta di pull
È possibile aggiungere un'etichetta a una richiesta di pull eseguendo il seguente comando:
$ cocoa label add --id 1 \
--label "deployed" \
--type pr \
--git-provider github \
--org <github-organization> \
--repo <github-repo-name>
elenco dei commenti alle richieste di modifica del cacao
Elenca tutti i commenti per una specifica Richiesta di modifica.
Opzioni:
Nota:
--lastdeve essere un numero non negativo.--beforee--afteraccettano date in formato ISO 8601 e non possono essere future.--beforeche--after, la data--beforedeve essere maggiore della data--after.--before,--after), poi--lastper limitare i risultati.Variabili di ambiente richieste, se si utilizza il fornitore ServiceNow v3:
Ulteriori variabili di ambiente, se si utilizza il fornitore ServiceNow v3:
Variabili d'ambiente necessarie per il provider GitLab:
Variabili di ambiente richieste per il provider GitHub Enterprise:
Esecuzione del comando:
# List all comments for a change request $ cocoa change-request comment list "CHGXXXXXXX" # List comments using GitHub Enterprise provider $ cocoa change-request comment list "CHGXXXXXXX" --provider='github-enterprise' # Get only the last 5 comments $ cocoa change-request comment list "CHGXXXXXXX" --last=5 # Get comments created before a specific date $ cocoa change-request comment list "CHGXXXXXXX" --before="2026-03-20T10:00:00Z" # Get comments created after a specific date $ cocoa change-request comment list "CHGXXXXXXX" --after="2026-03-15T08:00:00Z" # Get comments within a date range $ cocoa change-request comment list "CHGXXXXXXX" --after="2026-03-15T08:00:00Z" --before="2026-03-20T10:00:00Z" # Get the last 10 comments within a date range $ cocoa change-request comment list "CHGXXXXXXX" --after="2026-03-15T08:00:00Z" --before="2026-03-20T10:00:00Z" --last=10