Skip to content

Commit 33361e5

Browse files
filipi86claude
andcommitted
fix(banner): fix title frame overflow + center tagline + banner on --help
- Print DROGONSEC title outside boxLine to eliminate double-width character misalignment (█ and box-drawing chars render as 2 cols in some terminals, causing NSEC to overflow the right ║ border). The ╠═══╣ separators above/below visually enclose the title. - Center the ◆ HUNT VULNERABILITIES ◆ BREAK WALLS ◆ SECURE CODE ◆ line using centerIn() helper (pads to mid-point of inner frame width). - Show banner on drogonsec --help / drogonsec -h and all subcommand help (drogonsec scan --help) via SetHelpFunc override in root.go. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 5071552 commit 33361e5

2 files changed

Lines changed: 37 additions & 17 deletions

File tree

internal/cli/banner.go

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ func PrintDragonBanner() {
5050
return nCyan(" ║ ") + padTo(content, W-1) + nCyan("║")
5151
}
5252

53+
// centerIn centers content inside a boxLine (accounts for ANSI codes).
54+
centerIn := func(content string) string {
55+
vl := visualLen(content)
56+
pad := (W - 1 - vl) / 2
57+
if pad < 0 {
58+
pad = 0
59+
}
60+
return strings.Repeat(" ", pad) + content
61+
}
62+
5363
fmt.Println()
5464
fmt.Println(topBdr)
5565
fmt.Println(boxLine(
@@ -58,23 +68,24 @@ func PrintDragonBanner() {
5868
dim(" │ SAST · SCA · LEAKS · GIT-HISTORY · IaC")))
5969
fmt.Println(midBdr)
6070

61-
// ── DROGONSEC — large ASCII title (inside frame) ─────────────────────────
62-
fmt.Println(boxLine(""))
63-
fmt.Println(boxLine(title(` ██████╗ ██████╗ ██████╗ ██████╗ ██████╗ ███╗ ██╗███████╗███████╗ ██████╗`)))
64-
fmt.Println(boxLine(title(` ██╔══██╗██╔══██╗██╔═══██╗██╔════╝ ██╔═══██╗████╗ ██║██╔════╝██╔════╝██╔════╝`)))
65-
fmt.Println(boxLine(title(` ██║ ██║██████╔╝██║ ██║██║ ███╗██║ ██║██╔██╗██║███████╗█████╗ ██║ `)))
66-
fmt.Println(boxLine(title(` ██║ ██║██╔══██╗██║ ██║██║ ██║██║ ██║██║╚██╗██║╚════██║██╔══╝ ██║ `)))
67-
fmt.Println(boxLine(title(` ██████╔╝██║ ██║╚██████╔╝╚██████╔╝╚██████╔╝██║ ╚████║███████║███████╗╚██████╗`)))
68-
fmt.Println(boxLine(title(` ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚══════╝ ╚═════╝`)))
69-
fmt.Println(boxLine(""))
70-
71-
// ── Security statement (inside frame) ─────────────────────────────────────
72-
fmt.Println(boxLine(
73-
nMag("◆") + " " + bold("HUNT VULNERABILITIES") + " " +
74-
nMag("◆") + " " + bold("BREAK WALLS") + " " +
75-
nMag("◆") + " " + bold("SECURE CODE") + " " +
76-
nMag("◆")))
77-
fmt.Println(boxLine(""))
71+
// ── DROGONSEC — large ASCII title (outside boxLine to avoid double-width
72+
// character misalignment; the ╠═══╣ borders above and below act as frame)
73+
fmt.Println()
74+
fmt.Println(" " + title(` ██████╗ ██████╗ ██████╗ ██████╗ ██████╗ ███╗ ██╗███████╗███████╗ ██████╗`))
75+
fmt.Println(" " + title(` ██╔══██╗██╔══██╗██╔═══██╗██╔════╝ ██╔═══██╗████╗ ██║██╔════╝██╔════╝██╔════╝`))
76+
fmt.Println(" " + title(` ██║ ██║██████╔╝██║ ██║██║ ███╗██║ ██║██╔██╗██║███████╗█████╗ ██║ `))
77+
fmt.Println(" " + title(` ██║ ██║██╔══██╗██║ ██║██║ ██║██║ ██║██║╚██╗██║╚════██║██╔══╝ ██║ `))
78+
fmt.Println(" " + title(` ██████╔╝██║ ██║╚██████╔╝╚██████╔╝╚██████╔╝██║ ╚████║███████║███████╗╚██████╗`))
79+
fmt.Println(" " + title(` ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚══════╝ ╚═════╝`))
80+
fmt.Println()
81+
82+
// ── Security statement — centered inside frame ────────────────────────────
83+
fmt.Println(midBdr)
84+
stmt := nMag("◆") + " " + bold("HUNT VULNERABILITIES") + " " +
85+
nMag("◆") + " " + bold("BREAK WALLS") + " " +
86+
nMag("◆") + " " + bold("SECURE CODE") + " " +
87+
nMag("◆")
88+
fmt.Println(boxLine(centerIn(stmt)))
7889

7990
// ── Bottom box: capabilities + author tagline ─────────────────────────────
8091
fmt.Println(midBdr)

internal/cli/root.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ func init() {
4848

4949
viper.BindPFlag("verbose", rootCmd.PersistentFlags().Lookup("verbose"))
5050

51+
// Show banner on -h / --help for all commands.
52+
// PersistentPreRun handles banner for normal execution; Cobra skips
53+
// PreRun hooks for help, so we override HelpFunc here instead.
54+
origHelp := rootCmd.HelpFunc()
55+
rootCmd.SetHelpFunc(func(cmd *cobra.Command, args []string) {
56+
PrintDragonBanner()
57+
origHelp(cmd, args)
58+
})
59+
5160
// Register sub-commands
5261
rootCmd.AddCommand(scanCmd)
5362
rootCmd.AddCommand(versionCmd)

0 commit comments

Comments
 (0)