Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve logging when insights_core_gpg_check is disabled #90

Merged
merged 2 commits into from
Sep 29, 2023
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
1 change: 0 additions & 1 deletion src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ func main() {
defer logFile.Close()

config = loadConfigOrDefault(configFilePath)
log.Infoln("Configuration loaded: ", config)
defer os.Remove(*config.TemporaryWorkerDirectory)

// Dial the dispatcher on its well-known address.
Expand Down
20 changes: 12 additions & 8 deletions src/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ var verificationArgs = []string{

// Verify that no one tampered with yaml file
func verifyYamlFile(yamlData []byte) bool {

if !*config.VerifyYAML {
log.Warnln("WARNING: Playbook verification disabled.")
return true
}

// --payload here will be a no-op because no upload is performed when using the verifier
// but, it will allow us to update the egg!

env := os.Environ()

if !*config.InsightsCoreGPGCheck {
log.Infoln("Calling insights-client with --no-gpg to skip signature validation...")
// --payload here will be a no-op because no upload is performed when
// using the verifier but, it will allow us to update the egg!
verificationArgs = append(verificationArgs, "--no-gpg")
env = append(env, "BYPASS_GPG=True")
} else {
log.Infoln("Calling insights-client with gpg signature validation...")
}

cmd := exec.Command(verificationCommand, verificationArgs...)
Expand All @@ -72,9 +72,15 @@ func verifyYamlFile(yamlData []byte) bool {

output, err := cmd.Output()
if err != nil {
log.Errorln("ERROR: Unable to verify yaml file:", string(output), err)
log.Errorln("Unable to verify yaml file:", string(output), err)
return false
}

if !*config.InsightsCoreGPGCheck {
log.Infoln("GPG verification is disabled and thus considered as valid")
} else {
log.Infoln("Signature of yaml file is valid")
}
return true
}

Expand Down Expand Up @@ -103,13 +109,11 @@ func processSignedScript(incomingContent []byte) string {
}

// Verify signature
log.Infoln("Verifying signature ...")
signatureIsValid := verifyYamlFile(incomingContent)
if !signatureIsValid {
errorMsg := "Signature of yaml file is invalid"
return errorMsg
}
log.Infoln("Signature of yaml file is valid")

// Parse the YAML data into array consisting of items of expected structure
var signedYamlArray []signedYamlContent
Expand Down