fortify: print line after ps output
All checks were successful
Test / Create distribution (push) Successful in 1m43s
Test / Run NixOS test (push) Successful in 9m18s

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
Ophestra 2025-02-14 12:23:20 +09:00
parent 820f48ef94
commit 3fba33687b
Signed by: cat
SSH Key Fingerprint: SHA256:gQ67O0enBZ7UdZypgtspB2FDM1g3GVw8nX0XSdcFw8Q

View File

@ -3,7 +3,7 @@ package main
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
direct "os" "os"
"slices" "slices"
"strconv" "strconv"
"strings" "strings"
@ -31,7 +31,7 @@ func printShowSystem(short bool) {
return return
} }
w := tabwriter.NewWriter(direct.Stdout, 0, 1, 4, ' ', 0) w := tabwriter.NewWriter(os.Stdout, 0, 1, 4, ' ', 0)
fmt.Fprintf(w, "User:\t%d\n", info.User) fmt.Fprintf(w, "User:\t%d\n", info.User)
@ -51,7 +51,7 @@ func printShowInstance(instance *state.State, config *fst.Config, short bool) {
} }
now := time.Now().UTC() now := time.Now().UTC()
w := tabwriter.NewWriter(direct.Stdout, 0, 1, 4, ' ', 0) w := tabwriter.NewWriter(os.Stdout, 0, 1, 4, ' ', 0)
if config.Confinement.Sandbox == nil { if config.Confinement.Sandbox == nil {
fmt.Print("Warning: this configuration uses permissive defaults!\n\n") fmt.Print("Warning: this configuration uses permissive defaults!\n\n")
@ -249,11 +249,12 @@ func printPs(short bool) {
} }
// buffer output to reduce terminal activity // buffer output to reduce terminal activity
w := tabwriter.NewWriter(direct.Stdout, 0, 1, 4, ' ', 0) w := tabwriter.NewWriter(os.Stdout, 0, 1, 4, ' ', 0)
fmt.Fprintln(w, "\tInstance\tPID\tApp\tUptime\tEnablements\tCommand") fmt.Fprintln(w, "\tInstance\tPID\tApp\tUptime\tEnablements\tCommand")
for _, e := range exp { for _, e := range exp {
printInstance(w, e, now) printInstance(w, e, now)
} }
fmt.Fprintln(w)
if err := w.Flush(); err != nil { if err := w.Flush(); err != nil {
fmsg.Fatalf("cannot flush tabwriter: %v", err) fmsg.Fatalf("cannot flush tabwriter: %v", err)
} }
@ -280,7 +281,7 @@ func printInstance(w *tabwriter.Writer, e *expandedStateEntry, now time.Time) {
} }
func printJSON(v any) { func printJSON(v any) {
encoder := json.NewEncoder(direct.Stdout) encoder := json.NewEncoder(os.Stdout)
encoder.SetIndent("", " ") encoder.SetIndent("", " ")
if err := encoder.Encode(v); err != nil { if err := encoder.Encode(v); err != nil {
fmsg.Fatalf("cannot serialise: %v", err) fmsg.Fatalf("cannot serialise: %v", err)