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

ci: scan vulns and common errors #310

Merged
merged 3 commits into from
Jul 9, 2024
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
13 changes: 13 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,16 @@ jobs:
- name: Test
run: go test ./...
if: matrix.os != 'windows-latest'

govulncheck:
uses: charmbracelet/meta/.github/workflows/govulncheck.yml@main
with:
go-version: stable

semgrep:
uses: charmbracelet/meta/.github/workflows/semgrep.yml@main

ruleguard:
uses: charmbracelet/meta/.github/workflows/ruleguard.yml@main
with:
go-version: stable
2 changes: 1 addition & 1 deletion ansi/baseelement.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func renderText(w io.Writer, p termenv.Profile, rules StylePrimitive, s string)
out = out.Blink()
}

_, _ = w.Write([]byte(out.String()))
_, _ = io.WriteString(w, out.String())
}

func (e *BaseElement) Render(w io.Writer, ctx RenderContext) error {
Expand Down
3 changes: 1 addition & 2 deletions ansi/blockelement.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ func (e *BlockElement) Finish(w io.Writer, ctx RenderContext) error {
}

if e.Newline {
_, err = mw.Write([]byte("\n"))
if err != nil {
if _, err := io.WriteString(mw, "\n"); err != nil {
return err
}
}
Expand Down
4 changes: 2 additions & 2 deletions ansi/paragraph.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func (e *ParagraphElement) Render(w io.Writer, ctx RenderContext) error {
rules := ctx.options.Styles.Paragraph

if !e.First {
_, _ = w.Write([]byte("\n"))
_, _ = io.WriteString(w, "\n")
}
be := BlockElement{
Block: &bytes.Buffer{},
Expand Down Expand Up @@ -46,7 +46,7 @@ func (e *ParagraphElement) Finish(w io.Writer, ctx RenderContext) error {
if err != nil {
return err
}
_, _ = mw.Write([]byte("\n"))
_, _ = io.WriteString(mw, "\n")
}

renderText(w, ctx.options.ColorProfile, bs.Current().Style.StylePrimitive, rules.Suffix)
Expand Down
5 changes: 3 additions & 2 deletions ansi/renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (r *ANSIRenderer) renderNode(w util.BufWriter, source []byte, node ast.Node
writeTo = io.Writer(bs.Current().Block)
}

_, _ = writeTo.Write([]byte(e.Entering))
_, _ = io.WriteString(writeTo, e.Entering)
if e.Renderer != nil {
err := e.Renderer.Render(writeTo, r.context)
if err != nil {
Expand All @@ -128,7 +128,8 @@ func (r *ANSIRenderer) renderNode(w util.BufWriter, source []byte, node ast.Node
return ast.WalkStop, err
}
}
_, _ = bs.Current().Block.Write([]byte(e.Exiting))

_, _ = io.WriteString(bs.Current().Block, e.Exiting)
}

return ast.WalkContinue, nil
Expand Down
12 changes: 12 additions & 0 deletions glamour_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,15 @@ func TestCapitalization(t *testing.T) {
t.Errorf("Rendered output doesn't match!\nExpected: `\n%s`\nGot: `\n%s`\n", td, b)
}
}

func FuzzData(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
func() int {
_, err := RenderBytes(data, DarkStyle)
if err != nil {
return 0
}
return 1
}()
})
}
11 changes: 0 additions & 11 deletions testdata/fuzz/fuzz.go

This file was deleted.

Loading