Skip to content

Instantly share code, notes, and snippets.

View erikdubbelboer's full-sized avatar

Erik Dubbelboer erikdubbelboer

View GitHub Profile

Here are the potential issues found in the codebase:

  1. Ignored Sync Error in Logging (cmd/signaling/main.go)

    • File: cmd/signaling/main.go
    • Issue: logger.Sync() error is ignored with // nolint:errcheck. In production, this could lead to lost log entries during shutdown.
    • Fix: Handle the error or log it.
  2. Panic in Test Proxy (cmd/testproxy/main.go)

    • File: cmd/testproxy/main.go
  • Issue: HTTP handlers use panic(err) which crashes the server on errors. Not suitable for production.

Okay, this is a large codebase. Here's a breakdown of potential issues and bugs, focusing on areas that stand out:

cmd/signaling/main.go

  • Error Handling: The error handling in main.go is a bit aggressive. logger.Panic will terminate the application, which might not be desirable in a production environment. Consider using logger.Fatal or logging the error and attempting to recover.
  • Random Seed: While the code seeds the random number generator, seeding with time.Now().UnixNano() isn't ideal for security-sensitive applications. If the generated random numbers are used for any kind of security purpose (unlikely in this code, but worth noting), a more secure random source should be used.
  • Potential resource leak: I can't see a close DB connection anywhere. While the server has defer logger.Sync(), I can't see the DB connection to postgres closed correctly. While the cloudflare credentials client does have a defer cancel(), I can't see any defer cancel() for the DB connec
export function loadPokiSDK() {
const getParameterByName = (name) => {
const match = RegExp(`[?&]${name}=([^&]*)`).exec(window.location.search);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
};
const queue = [];
const isLocalhost = window.location.hostname === 'localhost';
window.PokiSDK = new Proxy(
package main
import (
"fmt"
"runtime"
"sync"
"sync/atomic"
"time"
)
@erikdubbelboer
erikdubbelboer / go.mod
Created September 18, 2021 20:15
fasthttp client timeout test
module test
go 1.17
require github.com/valyala/fasthttp v1.30.0
require (
github.com/andybalholm/brotli v1.0.2 // indirect
github.com/klauspost/compress v1.13.4 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
package main
import (
"fmt"
"io"
"io/ioutil"
"net"
"os"
"time"
)
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/tls"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
"fmt"