Skip to content

Commit

Permalink
Update deps. Minor casting security fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkorunic committed Sep 8, 2024
1 parent 2d058a1 commit d8b48fc
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toolchain go1.23.0
require (
github.com/BurntSushi/toml v1.4.0
github.com/KimMachineGun/automemlimit v0.6.1
github.com/PuerkitoBio/goquery v1.9.2
github.com/PuerkitoBio/goquery v1.10.0
github.com/Shopify/gomail v0.0.0-20220729171026-0784ece65e69
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de
github.com/avast/retry-go/v4 v4.6.0
Expand All @@ -29,6 +29,7 @@ require (
github.com/minio/sha256-simd v1.0.1
github.com/peterbourgon/ff/v4 v4.0.0-alpha.4
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
github.com/reiver/go-cast v0.0.0-20240904124821-be0103637c3f
github.com/rs/zerolog v1.33.0
github.com/slack-go/slack v0.14.0
github.com/tj/go-spin v1.1.0
Expand Down Expand Up @@ -84,6 +85,7 @@ require (
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/reiver/go-erorr v0.0.0-20240801233437-8cbde6d1fa3f // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
Expand Down
8 changes: 6 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/KimMachineGun/automemlimit v0.6.1 h1:ILa9j1onAAMadBsyyUJv5cack8Y1WT26yLj/V+ulKp8=
github.com/KimMachineGun/automemlimit v0.6.1/go.mod h1:T7xYht7B8r6AG/AqFcUdc7fzd2bIdBKmepfP2S1svPY=
github.com/PuerkitoBio/goquery v1.9.2 h1:4/wZksC3KgkQw7SQgkKotmKljk0M6V8TUvA8Wb4yPeE=
github.com/PuerkitoBio/goquery v1.9.2/go.mod h1:GHPCaP0ODyyxqcNoFGYlAprUFH81NuRPd0GX3Zu2Mvk=
github.com/PuerkitoBio/goquery v1.10.0 h1:6fiXdLuUvYs2OJSvNRqlNPoBm6YABE226xrbavY5Wv4=
github.com/PuerkitoBio/goquery v1.10.0/go.mod h1:TjZZl68Q3eGHNBA8CWaxAN7rOU1EbDz3CWuolcO5Yu4=
github.com/Shopify/gomail v0.0.0-20220729171026-0784ece65e69 h1:gPoXdwo3sKq8qcfMu/Nc/wkJMLKwe7kaG9Uo8tOj3cU=
github.com/Shopify/gomail v0.0.0-20220729171026-0784ece65e69/go.mod h1:RS+Gaowa0M+gCuiFAiRMGBCMqxLrNA7TESTU/Wbblm8=
github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss=
Expand Down Expand Up @@ -212,6 +212,10 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/reiver/go-cast v0.0.0-20240904124821-be0103637c3f h1:+xhln673LL2XG1qhsUG1e+HHdXm/lTWihmr5G815dMc=
github.com/reiver/go-cast v0.0.0-20240904124821-be0103637c3f/go.mod h1:baMIic1VWx4m5MRviwSyHFx1Z6POGMRrnVgsMvsLlAA=
github.com/reiver/go-erorr v0.0.0-20240801233437-8cbde6d1fa3f h1:D1QSxKHm8U73XhjsW3SFLkT0zT5pKJi+1KGboMhY1Rk=
github.com/reiver/go-erorr v0.0.0-20240801233437-8cbde6d1fa3f/go.mod h1:F0HbBf+Ak2ZlE8YkDW4Y+KxaUmT0KaaIJK6CXY3cJxE=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
Expand Down
7 changes: 5 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import (
sysdnotify "github.com/iguanesolutions/go-systemd/v5/notify"
sysdwatchdog "github.com/iguanesolutions/go-systemd/v5/notify/watchdog"
"github.com/mattn/go-isatty"
"github.com/reiver/go-cast"
"github.com/rs/zerolog"
"go.uber.org/automaxprocs/maxprocs"
)
Expand Down Expand Up @@ -110,8 +111,10 @@ func main() {
logLevel = zerolog.DebugLevel
} else {
if v, ok := os.LookupEnv("LOG_LEVEL"); ok {
if l, err := strconv.Atoi(v); err != nil {
logLevel = zerolog.Level(int8(l))
if l, err := strconv.Atoi(v); err == nil {
if l8, err := cast.Int8(l); err == nil {
logLevel = zerolog.Level(l8)
}
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion scrape/scrape.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,19 @@ import (
"github.com/dkorunic/e-dnevnik-bot/fetch"
"github.com/dkorunic/e-dnevnik-bot/logger"
"github.com/dkorunic/e-dnevnik-bot/msgtypes"
"github.com/reiver/go-cast"
)

// GetGradesAndEvents initiates fetching subjects, grades and exam events from remote e-dnevnik site, sends
// individual messages to a message channel and optionally returning an error.
func GetGradesAndEvents(ctx context.Context, ch chan<- msgtypes.Message, username, password string, retries uint) error {
err := func() error {
ctx, stop := context.WithTimeout(ctx, time.Duration(retries)*fetch.Timeout)
r64, err := cast.Int64(retries)
if err != nil {
r64 = 1
}

ctx, stop := context.WithTimeout(ctx, time.Duration(r64)*fetch.Timeout)
defer stop()

client, err := fetch.NewClientWithContext(ctx, username, password)
Expand Down

0 comments on commit d8b48fc

Please sign in to comment.