Skip to content

Remove git.tcp.direct/kayos/common dependency; replace squish with stdlib#2

Merged
bdk38 merged 2 commits intomainfrom
copilot/remove-squish-dependency
Mar 6, 2026
Merged

Remove git.tcp.direct/kayos/common dependency; replace squish with stdlib#2
bdk38 merged 2 commits intomainfrom
copilot/remove-squish-dependency

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 6, 2026

HellPot pulled in git.tcp.direct/kayos/common exclusively for squish.UnpackStr(), which decodes base64+gzip strings — trivially replicated with compress/gzip and encoding/base64 from the standard library.

Changes

  • heffalump/markov.go — drop squish import; add bytes, compress/gzip, encoding/base64; replace squish.UnpackStr(srcGz) with local unpackGzipBase64(srcGz)
  • internal/extra/banner.go — same import swap; replace squish.UnpackStr(in) with local unpackGzipBase64(in)
  • go.mod / go.sumgo mod tidy removes git.tcp.direct/kayos/common entirely

The helper added to each file:

func unpackGzipBase64(encoded string) (string, error) {
    decoded, err := base64.StdEncoding.DecodeString(encoded)
    if err != nil {
        return "", err
    }
    reader, err := gzip.NewReader(bytes.NewReader(decoded))
    if err != nil {
        return "", err
    }
    defer reader.Close()
    var buf bytes.Buffer
    if _, err := io.Copy(&buf, reader); err != nil {
        return "", err
    }
    return buf.String(), nil
}

No behavioral changes — pure dependency reduction.

Original prompt

Problem

HellPot currently depends on git.tcp.direct/kayos/common solely to use the squish package for decompressing gzipped+base64 encoded strings. This functionality is available in Go's standard library, making the external dependency unnecessary.

Objective

Replace squish.UnpackStr() with Go's standard library compression functions (compress/gzip and encoding/base64) and remove the git.tcp.direct/kayos/common dependency.

Changes Required

1. Update heffalump/markov.go

Replace the import:

// Remove this:
"git.tcp.direct/kayos/common/squish"

// Add these:
"bytes"
"compress/gzip"
"encoding/base64"

Replace the init() function's decompression:

func init() {
	// DefaultMarkovMap is a Markov chain based on src.
	src, err := unpackGzipBase64(srcGz)  // Changed from squish.UnpackStr
	if err != nil {
		panic(err)
	}
	if len(src) < 1 {
		panic("failed to unpack source")
	}
	DefaultMarkovMap = MakeMarkovMap(strings.NewReader(src))
	DefaultHeffalump = NewHeffalump(DefaultMarkovMap, 100*1<<10)
}

Add this helper function to heffalump/markov.go:

// unpackGzipBase64 decodes a base64-encoded gzipped string using Go's standard library
func unpackGzipBase64(encoded string) (string, error) {
	// Decode base64
	decoded, err := base64.StdEncoding.DecodeString(encoded)
	if err != nil {
		return "", err
	}

	// Decompress gzip
	reader, err := gzip.NewReader(bytes.NewReader(decoded))
	if err != nil {
		return "", err
	}
	defer reader.Close()

	// Read decompressed data
	var buf bytes.Buffer
	if _, err := io.Copy(&buf, reader); err != nil {
		return "", err
	}

	return buf.String(), nil
}

2. Update internal/extra/banner.go

Replace the import:

// Remove this:
"git.tcp.direct/kayos/common/squish"

// Add these:
"bytes"
"compress/gzip"
"encoding/base64"

Find where squish.UnpackStr() is called (likely in the process() or similar function) and replace with unpackGzipBase64().

Add the same unpackGzipBase64() helper function to this file as well.

3. Clean up dependencies

After making the code changes, run:

go mod tidy

This will automatically remove the git.tcp.direct/kayos/common dependency since it's no longer referenced.

Testing Requirements

  1. Build succeeds: go build ./cmd/HellPot
  2. Application starts: ./hellpot runs without errors
  3. Markov generation works: The heffalump seed text unpacks correctly
  4. Banner displays: The ASCII banner unpacks and displays on startup
  5. Bot traps respond: curl http://localhost:8080/wp-login.php returns Markov-generated text
  6. Dependency removed: Verify grep kayos go.mod returns nothing

Benefits

  • ✅ Reduces external dependencies
  • ✅ Uses stable, well-maintained standard library
  • ✅ Simpler dependency tree
  • ✅ Easier security auditing
  • ✅ Slightly smaller binary size

Notes

  • The unpackGzipBase64() function is functionally equivalent to squish.UnpackStr()
  • Both files need the helper function since Go doesn't allow cross-package helper functions without exports
  • No behavioral changes expected - this is purely a refactoring

This pull request was created from Copilot chat.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@bdk38 bdk38 marked this pull request as ready for review March 6, 2026 16:07
…rnal dependency

Co-authored-by: bdk38 <244781262+bdk38@users.noreply.github.com>
Copilot AI changed the title [WIP] Replace squish with standard library for decompression Remove git.tcp.direct/kayos/common dependency; replace squish with stdlib Mar 6, 2026
Copilot finished work on behalf of bdk38 March 6, 2026 16:09
@bdk38 bdk38 merged commit 520978c into main Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants