Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs.kosli.com/content/faq/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,17 @@ kosli attest generic Dockerfile true ...
```
The parser then sees `Dockerfile` and `true` as the two
arguments to `kosli attest generic`.

## Path/Image name is a single whitespace character!

In order to calculate the fingerprint for an artifact, Kosli requires the path to the relevant file or directory, or the relevant image name. The command typically takes the form:
```
kosli attest generic [IMAGE-NAME | FILE-PATH | DIR-PATH] [flags]
```

When using multi-line commands in the shell or a script, if the image name or path has not been provided as above and whitespace has unintentionally been added after the line-continuation backslash on one of the lines, this whitespace character is interpreted as the name or path.

If you're using multi-line commands and receive an error message similar to this, check your command for extraneous whitespace:
```
Error: failed to calculate artifact fingerprint: stat : no such file or directory. The directory path is ' '.
```
12 changes: 12 additions & 0 deletions internal/digest/digest.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ func DirSha256(dirPath string, excludePaths []string, logger *logger.Logger) (st
logger.Debug("calculating fingerprint for path [%s] -- excluding paths: %s", dirPath, excludePaths)
info, err := os.Stat(dirPath)
if err != nil {
if dirPath == " " {
return "", fmt.Errorf("%s. The directory path is '%s'. https://docs.kosli.com/faq/#pathimage-name-is-a-single-whitespace-character", err, dirPath)
}
return "", err
}
if !info.IsDir() {
Expand Down Expand Up @@ -83,6 +86,9 @@ func OciSha256(artifactName string, registryUsername string, registryPassword st
// Parse image reference
ref, err := docker.ParseReference(imageName)
if err != nil {
if artifactName == " " {
return "", fmt.Errorf("%w. The artifact name is '%s'. https://docs.kosli.com/faq/#pathimage-name-is-a-single-whitespace-character", err, artifactName)
}
return "", fmt.Errorf("failed to parse image reference for %s: %w", imageName, err)
}

Expand Down Expand Up @@ -171,6 +177,9 @@ func FileSha256(filepath string) (string, error) {
hasher := sha256.New()
f, err := os.Open(filepath)
if err != nil {
if filepath == " " {
return "", fmt.Errorf("%s. The filename is '%s'. https://docs.kosli.com/faq/#pathimage-name-is-a-single-whitespace-character", err, filepath)
}
return "", err
}
defer f.Close()
Expand All @@ -191,6 +200,9 @@ func DockerImageSha256(imageID string) (string, error) {
}
imageInspect, err := cli.ImageInspect(context.Background(), imageID)
if err != nil {
if imageID == " " {
return "", fmt.Errorf("%s. The image ID is '%s'. https://docs.kosli.com/faq/#pathimage-name-is-a-single-whitespace-character", err, imageID)
}
return "", err
}
repoDigests := imageInspect.RepoDigests
Expand Down