Skip to content

Commit a1820ee

Browse files
committed
Add README.md; Fix doc.go documentation
Signed-off-by: plar <laxkin@gmail.com>
1 parent 5cf5485 commit a1820ee

2 files changed

Lines changed: 59 additions & 5 deletions

File tree

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# SafeCLI: Secure Command Line Interface Package
2+
3+
SafeCLI is a specialized Go package aimed at facilitating the secure construction, redaction, and logging of command-line arguments. It's designed particularly to handle sensitive values, ensuring they are managed securely throughout the process of command-line argument preparation and execution. This package is part of the Kanister project.
4+
5+
## Features
6+
7+
- **Secure Argument Handling**: Safely handles sensitive information in command-line arguments, ensuring that sensitive details are never exposed in logs or error messages.
8+
- **Flexible CLI Construction**: Provides a builder pattern for constructing command-line arguments dynamically, allowing for clean and readable code.
9+
- **Redaction Interface**: Integrates a redaction system that automatically obscures sensitive information when arguments are converted to strings for logging or debugging.
10+
- **Logging Utility**: Includes a logging utility that ensures sensitive information is redacted, while still providing helpful output for debugging and monitoring.
11+
12+
## Installation
13+
14+
You can install SafeCLI by running:
15+
16+
```bash
17+
go get -u github.com/kanisterio/safecli
18+
```
19+
20+
## Usage
21+
22+
### Basic CLI Construction
23+
24+
To construct a CLI command, you can use the `NewBuilder` function which initializes a new command builder. You can append arguments, both loggable and sensitive, to the builder:
25+
26+
```go
27+
import "github.com/kanisterio/safecli"
28+
29+
func main() {
30+
builder := safecli.NewBuilder("zip").
31+
AppendLoggableKV("--output", "/path/to/output").
32+
AppendRedactedKV("--password", "secretPass").
33+
AppendLoggable("input_file1", "input_file2")
34+
35+
command := builder.Build()
36+
// Use `command` as required, e.g., execute it
37+
}
38+
```
39+
40+
In the above example, `--password` is a sensitive argument, and its value will be redacted in logs.
41+
42+
### Secure Logging
43+
44+
To log a CLI command securely, ensuring that sensitive information is redacted:
45+
46+
```go
47+
logger := safecli.NewLogger(builder)
48+
logOutput := logger.Log()
49+
// Use `logOutput` for logging
50+
```
51+
52+
## Contribution
53+
54+
Contributions to the SafeCLI package are welcome. Please follow the contribution guidelines of the Kanister project when submitting patches or features.

doc.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,30 @@
44
// you may not use this file except in compliance with the License.
55
// You may obtain a copy of the License at
66
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
7+
// http://www.apache.org/licenses/LICENSE-2.0
88
//
99
// Unless required by applicable law or agreed to in writing, software
1010
// distributed under the License is distributed on an "AS IS" BASIS,
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14+
package safecli
1415

1516
// Package safecli provides functionality for building, redacting, and logging command-line arguments.
1617
// It is designed to handle sensitive values securely
1718
// while also providing utility for CLI construction and logging.
18-
package safecli
19-
19+
//
2020
// The package offers two concrete builder functions:
2121
// - NewBuilder: Creates a new CLI builder, allowing for flexible CLI creation.
2222
// - NewLogger: Creates a new CLI logger for safely CLI logging.
23-
23+
//
2424
// Usage example:
2525
//
2626
// package main
2727
//
2828
// import (
2929
// "fmt"
30-
// "safecli"
30+
// "github.com/kanisterio/safecli"
3131
// )
3232
//
3333
// func main() {

0 commit comments

Comments
 (0)