Skip to content

Commit 56d0747

Browse files
spbsolubleKeyfactor
andauthored
Epic 54795 (#160)
* fix(ci): Add KFC 11.x test labs * fix(store-types): Store type create omits empty fields. * fix(pam-types): `types-list` does not crash on nil httpResponse. * chore: Update license year, and bump AKV runner go version * fix(tests): Remove "ProviderTypeParams" from pam-types tests for KFC v11.0.0+ * fix(tests): Fix nil pointer issues on tests. * feat(stores): `stores export` now allows for `--all` and user interactive exports --------- Signed-off-by: sbailey <1661003+spbsoluble@users.noreply.github.com> Co-authored-by: Keyfactor <keyfactor@keyfactor.github.io>
1 parent 7447624 commit 56d0747

104 files changed

Lines changed: 2115 additions & 845 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/tests.yml

Lines changed: 110 additions & 246 deletions
Large diffs are not rendered by default.

.github/workflows/update-stores.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
sparse-checkout: |
7171
.github
7272
path: './merge-folder/'
73-
token: ${{ secrets.SDK_SYNC_PAT }}
73+
token: ${{ secrets.V2BUILDTOKEN }}
7474
ref: '${{env.KFUTIL_ARG}}'
7575

7676
# If the branch does not exist, first check out the main branch from kfutil.
@@ -82,7 +82,7 @@ jobs:
8282
sparse-checkout: |
8383
.github
8484
path: './merge-folder/'
85-
token: ${{ secrets.SDK_SYNC_PAT }}
85+
token: ${{ secrets.V2BUILDTOKEN }}
8686

8787
# Save a copy of the original json
8888
- name: Save original store_types.json
@@ -96,15 +96,15 @@ jobs:
9696
with:
9797
repository: 'keyfactor/integration-tools'
9898
path: './tools/'
99-
token: ${{ secrets.SDK_SYNC_PAT }}
99+
token: ${{ secrets.V2BUILDTOKEN }}
100100

101101
- name: Run Python Script
102102
working-directory: ./tools/store-type-merge
103103
run: |
104104
python main.py --repo-name ${{ env.KFUTIL_ARG }} --ref ${{ env.TARGET_REPO_BRANCH }}
105105
cat store_types.json
106106
env:
107-
GITHUB_TOKEN: ${{ secrets.SDK_SYNC_PAT }}
107+
GITHUB_TOKEN: ${{ secrets.V2BUILDTOKEN }}
108108

109109
- name: Save Store Types JSON Artifact
110110
if: success()
@@ -194,4 +194,4 @@ jobs:
194194
});
195195
console.log(`Pull request created: ${{env.KFUTIL_ARG}}:${{env.TARGET_REPO_BRANCH}} : ${response.data.html_url}`);
196196
env:
197-
GITHUB_TOKEN: ${{ secrets.SDK_SYNC_PAT }}
197+
GITHUB_TOKEN: ${{ secrets.V2BUILDTOKEN }}

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
# v1.4.0
2+
## Features
3+
4+
### Stores
5+
- `stores import generate-template`: New sub CLI to generate a CSV template for bulk importing stores. [See docs](docs/kfutil_stores_import_generate-template.md)`.
6+
- `stores delete`: Support for user interactive mode.
7+
- `stores delete`: Support of delete from CSV file.
8+
- `stores export`: Supports `--all` flag and user interactive mode
9+
10+
## Fixes
11+
- Various null pointer references when nothing and/or empty inputs/responses are received.
12+
- Installer script checksum check now validates properly. #119
13+
- `stores import` sub CLI is now listed and documented #71
14+
15+
### Store Types
16+
- Empty `storepath` values are no longer passed to the API. #56
17+
18+
### PAM Types
19+
- Handle duplicate provider type that is already created without crashing. #139
20+
21+
## Docs
22+
- [Examples for certificate store bulk operations](https://github.com/Keyfactor/kfutil/tree/epic_54795/examples/cert_stores/bulk_operations#readme)
23+
124
# v1.3.2
225

326
### Package

GNUmakefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ endif
1313
OS_ARCH := $(shell go env GOOS)_$(shell go env GOARCH)
1414
BASEDIR := ${HOME}/go/bin
1515
INSTALLDIR := ${BASEDIR}
16+
MARKDOWN_FILE := README.md
17+
TEMP_TOC_FILE := temp_toc.md
18+
19+
1620

1721
default: build
1822

@@ -71,4 +75,13 @@ prerelease: fmt setversion
7175
git tag $(VERSION)
7276
git push origin $(VERSION)
7377

78+
check_toc:
79+
@grep -q 'TOC_START' $(MARKDOWN_FILE) && echo "TOC already exists." || (echo "TOC not found. Generating..." && $(MAKE) generate_toc)
80+
81+
generate_toc:
82+
# check if markdown-toc is installed and if not install it
83+
@command -v markdown-toc >/dev/null 2>&1 || (echo "markdown-toc is not installed. Installing..." && npm install -g markdown-toc)
84+
markdown-toc -i $(MARKDOWN_FILE) --skip 'Table of Contents'
85+
86+
7487
.PHONY: build prerelease release install test fmt vendor version setversion

README.md

Lines changed: 71 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,46 @@
1-
21
# Keyfactor Command Utility (kfutil)
32

43
`kfutil` is a go-lang CLI wrapper for Keyfactor Command API. It also includes other utility/helper functions around automating common Keyfactor Command operations.
54

65
#### Integration status: Production - Ready for use in production environments.
76

7+
<!-- toc -->
8+
9+
- [About the Keyfactor API Client](#about-the-keyfactor-api-client)
10+
- [Support for Keyfactor Command Utility (kfutil)](#support-for-keyfactor-command-utility-kfutil)
11+
- [Quickstart](#quickstart)
12+
* [Linux/MacOS](#linuxmacos)
13+
+ [Prerequisites:](#prerequisites)
14+
+ [Installation:](#installation)
15+
* [Windows](#windows)
16+
+ [Prerequisites:](#prerequisites-1)
17+
+ [Installation:](#installation-1)
18+
- [Environmental Variables](#environmental-variables)
19+
* [Linux/MacOS:](#linuxmacos)
20+
* [Windows Powershell:](#windows-powershell)
21+
- [Authentication Providers](#authentication-providers)
22+
- [Commands](#commands)
23+
* [Login](#login)
24+
* [Logout](#logout)
25+
- [Commands](#commands-1)
26+
* [Bulk operations](#bulk-operations)
27+
+ [Bulk create cert stores](#bulk-create-cert-stores)
28+
+ [Bulk create cert store types](#bulk-create-cert-store-types)
29+
* [Root of Trust](#root-of-trust)
30+
+ [Quickstart](#quickstart-1)
31+
+ [Generate Certificate List Template](#generate-certificate-list-template)
32+
+ [Generate Certificate Store List Template](#generate-certificate-store-list-template)
33+
+ [Run Root of Trust Audit](#run-root-of-trust-audit)
34+
+ [Run Root of Trust Reconcile](#run-root-of-trust-reconcile)
35+
* [Certificate Store Inventory](#certificate-store-inventory)
36+
+ [Show the inventory of a certificate store](#show-the-inventory-of-a-certificate-store)
37+
+ [Add certificates to certificate stores](#add-certificates-to-certificate-stores)
38+
+ [Remove certificates from certificate stores](#remove-certificates-from-certificate-stores)
39+
- [Development](#development)
40+
* [Adding a new command](#adding-a-new-command)
41+
42+
<!-- tocstop -->
43+
844
## About the Keyfactor API Client
945

1046
This API client allows for programmatic management of Keyfactor resources.
@@ -13,18 +49,12 @@ This API client allows for programmatic management of Keyfactor resources.
1349

1450
Keyfactor Command Utility (kfutil) is open source and supported on best effort level for this tool/library/client. This means customers can report Bugs, Feature Requests, Documentation amendment or questions as well as requests for customer information required for setup that needs Keyfactor access to obtain. Such requests do not follow normal SLA commitments for response or resolution. If you have a support issue, please open a support ticket via the Keyfactor Support Portal at https://support.keyfactor.com/
1551

16-
###### To report a problem or suggest a new feature, use the **[Issues](../../issues)** tab. If you want to contribute actual bug fixes or proposed enhancements, use the **[Pull requests](../../pulls)** tab.
17-
18-
---
19-
20-
21-
---
22-
23-
52+
[!NOTE] To report a problem or suggest a new feature, use the **[Issues](../../issues)** tab. If you want to contribute actual bug fixes or proposed enhancements, use the **[Pull requests](../../pulls)** tab.
2453

2554
## Quickstart
2655

27-
### Prerequisites:
56+
### Linux/MacOS
57+
#### Prerequisites:
2858
- [jq](https://stedolan.github.io/jq/download/) CLI tool, used to parse JSON output.
2959
- Either
3060
- [curl](https://curl.se/download.html) CLI tool, used to download the release files.
@@ -33,22 +63,24 @@ Keyfactor Command Utility (kfutil) is open source and supported on best effort l
3363
- [openssl](https://www.openssl.org/source/) CLI tool, used to validate package checksum.
3464
- `$HOME/.local/bin` in your `$PATH` and exists if not running as root, else `/usr/local/bin` if running as root.
3565

36-
### Installation:
37-
38-
#### Linux/MacOS
66+
#### Installation:
3967
```bash
4068
bash <(curl -s https://raw.githubusercontent.com/Keyfactor/kfutil/main/install.sh)
4169
````
4270

43-
#### Windows (or Linux/MacOS if PowerShell is preferred)
71+
### Windows
72+
#### Prerequisites:
73+
- Powershell 5.1 or later
74+
75+
#### Installation:
4476
```powershell
4577
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/Keyfactor/kfutil/main/install.ps1" -OutFile "install.ps1"
4678
# Install kfutil to $HOME/AppData/Local/Microsoft/WindowsApps.
4779
# Use Get-Help .\install.ps1 -Full for help and examples.
4880
.\install.ps1
4981
```
5082

51-
### Environmental Variables
83+
## Environmental Variables
5284

5385
All the variables listed below need to be set in your environment. The `kfutil` command will look for these variables
5486
and use them if they are set. If they are not set, the utility will fail to connect to Keyfactor.
@@ -63,7 +95,7 @@ and use them if they are set. If they are not set, the utility will fail to conn
6395
| KFUTIL_EXP | Set to `1` or `true` to enable experimental features. |
6496
| KFUTIL_DEBUG | Set to `1` or `true` to enable debug logging. |
6597

66-
Linux/MacOS:
98+
### Linux/MacOS:
6799

68100
```bash
69101
export KEYFACTOR_HOSTNAME="<mykeyfactorhost.mydomain.com>"
@@ -80,7 +112,7 @@ export KFUTIL_EXP=0 # Set to 1 or true to enable experimental features
80112
export KFUTIL_DEBUG=0 # Set to 1 or true to enable debug logging
81113
```
82114

83-
Windows Powershell:
115+
### Windows Powershell:
84116

85117
```powershell
86118
$env:KEYFACTOR_HOSTNAME = "<mykeyfactorhost.mydomain.com>"
@@ -138,29 +170,45 @@ kfutil logout
138170

139171
#### Bulk create cert stores
140172

141-
For full documentation, see [stores import](docs/kfutil_stores_import.md).
173+
For full documentation, see [stores import](docs/kfutil_stores_import.md). For a full user-interactive guide, see the
174+
[stores bulk operations examples](examples/cert_stores/bulk_operations/README.md).
142175

143176
This will attempt to process a CSV input file of certificate stores to create. The template can be generated by
144177
running: `kfutil stores import generate-template` command.
145178

146179
```bash
147-
kfutil stores import create --file <file name to import> --store-type-id <store type id> --store-type-name <store type name> --results-path <filepath for results> --dry-run <check fields only> [flags]
180+
kfutil stores import csv --file <file name to import>
148181
```
149182

150183
```bash
151-
kfutil stores import --help
152-
Tool for generating import templates and importing certificate stores
184+
kfutil stores import --help
185+
Tools for generating import templates and importing certificate stores
153186
154187
Usage:
155188
kfutil stores import [command]
156189
157190
Available Commands:
158-
create Create certificate stores
191+
csv Create certificate stores from CSV file.
159192
generate-template For generating a CSV template with headers for bulk store creation.
160193
161194
Flags:
162195
-h, --help help for import
163196
197+
Global Flags:
198+
--api-path string API Path to use for authenticating to Keyfactor Command. (default is KeyfactorAPI) (default "KeyfactorAPI")
199+
--auth-provider-profile string The profile to use defined in the securely stored config. If not specified the config named 'default' will be used if it exists. (default "default")
200+
--auth-provider-type string Provider type choices: (azid)
201+
--config string Full path to config file in JSON format. (default is $HOME/.keyfactor/command_config.json)
202+
--debug Enable debugFlag logging.
203+
--domain string Domain to use for authenticating to Keyfactor Command.
204+
--exp Enable expEnabled features. (USE AT YOUR OWN RISK, these features are not supported and may change or be removed at any time.)
205+
--format text How to format the CLI output. Currently only text is supported. (default "text")
206+
--hostname string Hostname to use for authenticating to Keyfactor Command.
207+
--no-prompt Do not prompt for any user input and assume defaults or environmental variables are set.
208+
--password string Password to use for authenticating to Keyfactor Command. WARNING: Remember to delete your console history if providing kfcPassword here in plain text.
209+
--profile string Use a specific profile from your config file. If not specified the config named 'default' will be used if it exists.
210+
--username string Username to use for authenticating to Keyfactor Command.
211+
164212
Use "kfutil stores import [command] --help" for more information about a command.
165213
```
166214
@@ -203,7 +251,7 @@ For full documentation, see [stores rot](docs/kfutil_stores_rot.md).
203251
The root of trust (rot) utility is a tool that allows you to bulk manage Keyfactor certificate stores and ensure that a
204252
set of defined certificates are present in each store that meets a certain set of criteria or no criteria at all.
205253
206-
### Root of Trust Quickstart
254+
#### Quickstart
207255
208256
```bash
209257
echo "Generating cert template file certs_template.csv"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "string",
3+
"remote": true,
4+
"area": 0,
5+
"services": {
6+
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
7+
},
8+
"providerTypeParamValues": [
9+
{
10+
"id": 0,
11+
"value": "string",
12+
"instanceId": 0,
13+
"instanceGuid": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
14+
"providerTypeParam": {
15+
"id": 0,
16+
"name": "string",
17+
"displayName": "string",
18+
"instanceLevel": true
19+
}
20+
}
21+
],
22+
"securedAreaId": 0
23+
}

cmd/auth_providers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 Keyfactor
1+
// Copyright 2024 Keyfactor
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

cmd/certificates.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Package cmd Copyright 2023 Keyfactor
1+
// Copyright 2024 Keyfactor
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

cmd/constants.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Package cmd Copyright 2023 Keyfactor
1+
// Copyright 2024 Keyfactor
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -25,6 +25,10 @@ const (
2525
XKeyfactorRequestedWith = "APIClient"
2626
XKeyfactorApiVersion = "1"
2727
FlagGitRef = "git-ref"
28+
FlagFromFile = "from-file"
29+
DebugFuncEnter = "entered: %s"
30+
DebugFuncExit = "exiting: %s"
31+
DebugFuncCall = "calling: %s"
2832
)
2933

3034
var ProviderTypeChoices = []string{

cmd/containers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Package cmd Copyright 2023 Keyfactor
1+
// Copyright 2024 Keyfactor
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)