From 39205402ce823503cb90336b92c78432dbdbde1b Mon Sep 17 00:00:00 2001 From: Brian Gann Date: Thu, 26 Sep 2024 23:47:28 -0400 Subject: [PATCH 01/10] update ci --- .github/workflows/ci.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad9d203..4abb473 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,12 +25,11 @@ jobs: run: go get . - name: Install golangci-lint - uses: golangci/golangci-lint-action@v4 + uses: golangci/golangci-lint-action@v6 with: version: latest args: --exclude-use-default skip-cache: true - skip-pkg-cache: true - name: Run Gosec Security Scanner uses: securego/gosec@master @@ -51,7 +50,7 @@ jobs: args: -v build:ci - name: Upload Code Climate Report - uses: paambaati/codeclimate-action@v5.0.0 + uses: paambaati/codeclimate-action@v9 env: CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}} with: @@ -95,7 +94,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} if: startsWith(github.ref, 'refs/tags/v') with: - draft: true + prerelease: true generate_release_notes: true files: | ./grafana-kiosk-v*/** From c40866fd24cf236a6c3174045215a70c80de7c17 Mon Sep 17 00:00:00 2001 From: Brian Gann Date: Thu, 26 Sep 2024 23:48:01 -0400 Subject: [PATCH 02/10] enable page load parameter as argument --- pkg/cmd/grafana-kiosk/main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/cmd/grafana-kiosk/main.go b/pkg/cmd/grafana-kiosk/main.go index 7a81ce2..3808ba3 100644 --- a/pkg/cmd/grafana-kiosk/main.go +++ b/pkg/cmd/grafana-kiosk/main.go @@ -35,6 +35,7 @@ type Args struct { LoginMethod string URL string Username string + PageLoadDelayMS int64 Password string UsernameField string PasswordField string @@ -58,6 +59,7 @@ func ProcessArgs(cfg interface{}) Args { flagSettings.StringVar(&processedArgs.WindowPosition, "window-position", "0,0", "Top Left Position of Kiosk") flagSettings.StringVar(&processedArgs.WindowSize, "window-size", "", "Size of Kiosk in pixels (width,height)") flagSettings.StringVar(&processedArgs.ScaleFactor, "scale-factor", "1.0", "Scale factor, sort of zoom") + flagSettings.Int64Var(&processedArgs.PageLoadDelayMS, "page-load-delay-ms", 2000, "Delay in milliseconds before navigating to URL") flagSettings.BoolVar(&processedArgs.IsPlayList, "playlists", false, "URL is a playlist") flagSettings.BoolVar(&processedArgs.AutoFit, "autofit", true, "Fit panels to screen") flagSettings.BoolVar(&processedArgs.LXDEEnabled, "lxde", false, "Initialize LXDE for kiosk mode") @@ -125,6 +127,7 @@ func summary(cfg *kiosk.Config) { log.Println("WindowPosition:", cfg.General.WindowPosition) log.Println("WindowSize:", cfg.General.WindowSize) log.Println("ScaleFactor:", cfg.General.ScaleFactor) + log.Println("PageLoadDelayMS:", cfg.General.PageLoadDelayMS) // target log.Println("URL:", cfg.Target.URL) log.Println("LoginMethod:", cfg.Target.LoginMethod) @@ -186,6 +189,7 @@ func main() { cfg.General.WindowPosition = args.WindowPosition cfg.General.WindowSize = args.WindowSize cfg.General.ScaleFactor = args.ScaleFactor + cfg.General.PageLoadDelayMS = args.PageLoadDelayMS // cfg.GoAuth.AutoLogin = args.OauthAutoLogin cfg.GoAuth.UsernameField = args.UsernameField From 04624aeeb45790cd76aa86d3d55714e31fb4c4af Mon Sep 17 00:00:00 2001 From: Brian Gann Date: Thu, 26 Sep 2024 23:48:24 -0400 Subject: [PATCH 03/10] add sleeps between bypass steps --- pkg/kiosk/local_login.go | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/pkg/kiosk/local_login.go b/pkg/kiosk/local_login.go index 2951c66..e7bfcee 100644 --- a/pkg/kiosk/local_login.go +++ b/pkg/kiosk/local_login.go @@ -57,21 +57,46 @@ func GrafanaKioskLocal(cfg *Config, messages chan string) { baseURL := cfg.Target.URL[:endIndex] bypassURL := baseURL + "/login/local" - log.Println("Bypassing Azure AD autoLogin at ", bypassURL) + log.Println("Bypassing autoLogin using URL ", bypassURL) if err := chromedp.Run(taskCtx, chromedp.Navigate(bypassURL), + chromedp.ActionFunc(func(context.Context) error { + log.Printf("Sleeping %d MS before checking for login fields", cfg.General.PageLoadDelayMS) + time.Sleep(time.Duration(cfg.General.PageLoadDelayMS) * time.Millisecond) + return nil + }), chromedp.WaitVisible(`//input[@name="user"]`, chromedp.BySearch), chromedp.SendKeys(`//input[@name="user"]`, cfg.Target.Username, chromedp.BySearch), chromedp.SendKeys(`//input[@name="password"]`, cfg.Target.Password+kb.Enter, chromedp.BySearch), + chromedp.ActionFunc(func(context.Context) error { + log.Printf("Sleeping %d MS before checking for topnav", cfg.General.PageLoadDelayMS) + time.Sleep(time.Duration(cfg.General.PageLoadDelayMS) * time.Millisecond) + return nil + }), chromedp.WaitVisible(`//img[@alt="User avatar"]`, chromedp.BySearch), + chromedp.ActionFunc(func(context.Context) error { + log.Printf("Sleeping %d MS before navigating to final url", cfg.General.PageLoadDelayMS) + time.Sleep(time.Duration(cfg.General.PageLoadDelayMS) * time.Millisecond) + return nil + }), chromedp.Navigate(generatedURL), ); err != nil { panic(err) } } else { if err := chromedp.Run(taskCtx, + chromedp.ActionFunc(func(context.Context) error { + log.Printf("Sleeping %d MS before navigating to final url", cfg.General.PageLoadDelayMS) + time.Sleep(time.Duration(cfg.General.PageLoadDelayMS) * time.Millisecond) + return nil + }), chromedp.Navigate(generatedURL), + chromedp.ActionFunc(func(context.Context) error { + log.Printf("Sleeping %d MS before checking for login fields", cfg.General.PageLoadDelayMS) + time.Sleep(time.Duration(cfg.General.PageLoadDelayMS) * time.Millisecond) + return nil + }), chromedp.WaitVisible(`//input[@name="user"]`, chromedp.BySearch), chromedp.SendKeys(`//input[@name="user"]`, cfg.Target.Username, chromedp.BySearch), chromedp.SendKeys(`//input[@name="password"]`, cfg.Target.Password+kb.Enter, chromedp.BySearch), From 0bf885ad70f2f11daa78e53cfcf37ae0eef470a2 Mon Sep 17 00:00:00 2001 From: Brian Gann Date: Thu, 26 Sep 2024 23:58:35 -0400 Subject: [PATCH 04/10] add archiving --- .github/workflows/ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4abb473..7cb5ec9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,6 +49,13 @@ jobs: version: latest args: -v build:ci + - name: Archive Build + uses: actions/upload-artifact@v4 + with: + name: grafana-kiosk + path: bin + retention-days: 7 + - name: Upload Code Climate Report uses: paambaati/codeclimate-action@v9 env: From 87441a46fe2174ab4d5c5563818ac67bbdeb58c1 Mon Sep 17 00:00:00 2001 From: Brian Gann Date: Fri, 27 Sep 2024 00:06:45 -0400 Subject: [PATCH 05/10] update archive --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7cb5ec9..9401439 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,9 +51,12 @@ jobs: - name: Archive Build uses: actions/upload-artifact@v4 + env: + SOURCE_TAG: ${{ steps.branch_name.outputs.SOURCE_TAG }} with: - name: grafana-kiosk + name: grafana-kiosk-$SOURCE_TAG.zip path: bin + overwrite: true retention-days: 7 - name: Upload Code Climate Report From c36d4106c85ae64bfb14d34a030f397b6a548392 Mon Sep 17 00:00:00 2001 From: Brian Gann Date: Fri, 27 Sep 2024 00:13:33 -0400 Subject: [PATCH 06/10] update archive --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9401439..95d9161 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,10 +51,10 @@ jobs: - name: Archive Build uses: actions/upload-artifact@v4 - env: - SOURCE_TAG: ${{ steps.branch_name.outputs.SOURCE_TAG }} + #env: + # SOURCE_TAG: ${{ steps.branch_name.outputs.SOURCE_TAG }} with: - name: grafana-kiosk-$SOURCE_TAG.zip + name: grafana-kiosk-${{ steps.branch_name.outputs.SOURCE_TAG }}.zip path: bin overwrite: true retention-days: 7 From eb0c93482f4db33ac7e9408b13adcbbe383cf1a7 Mon Sep 17 00:00:00 2001 From: Brian Gann Date: Fri, 27 Sep 2024 00:22:33 -0400 Subject: [PATCH 07/10] update archive --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 95d9161..1c6cc26 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,9 +52,9 @@ jobs: - name: Archive Build uses: actions/upload-artifact@v4 #env: - # SOURCE_TAG: ${{ steps.branch_name.outputs.SOURCE_TAG }} + # PR_NUMBER: ${{ github.event.number }} with: - name: grafana-kiosk-${{ steps.branch_name.outputs.SOURCE_TAG }}.zip + name: grafana-kiosk-${{github.event.number}}.zip path: bin overwrite: true retention-days: 7 From dda941e735b04b30a623ae6d692dea46692839f9 Mon Sep 17 00:00:00 2001 From: Brian Gann Date: Fri, 27 Sep 2024 00:25:24 -0400 Subject: [PATCH 08/10] update archive --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1c6cc26..2efe963 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,10 +51,10 @@ jobs: - name: Archive Build uses: actions/upload-artifact@v4 - #env: - # PR_NUMBER: ${{ github.event.number }} + env: + PR_NUMBER: ${{ github.event.number }} with: - name: grafana-kiosk-${{github.event.number}}.zip + name: grafana-kiosk-${{env.PR_NUMBER}}.zip path: bin overwrite: true retention-days: 7 From 5155140146f6475b57fba001c379bc1e01ea21a7 Mon Sep 17 00:00:00 2001 From: Brian Gann Date: Fri, 27 Sep 2024 00:45:18 -0400 Subject: [PATCH 09/10] update archive --- .github/workflows/ci.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2efe963..ceb631d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,12 +49,19 @@ jobs: version: latest args: -v build:ci + - name: Get PR + uses: jwalton/gh-find-current-pr@master + id: findPr + with: + state: open + - name: Archive Build uses: actions/upload-artifact@v4 + if: success() && steps.findPr.outputs.number env: - PR_NUMBER: ${{ github.event.number }} + PR: ${{ steps.findPr.outputs.pr }} with: - name: grafana-kiosk-${{env.PR_NUMBER}}.zip + name: grafana-kiosk-${{env.PR}}.zip path: bin overwrite: true retention-days: 7 From cbe20a8a5c054433c9d3a0c35fe0f4af77b3a2aa Mon Sep 17 00:00:00 2001 From: Brian Gann Date: Fri, 27 Sep 2024 00:49:22 -0400 Subject: [PATCH 10/10] update archive --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ceb631d..2844bcf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,7 +36,7 @@ jobs: with: args: ./... - - name: Branch name + - name: Get BRANCH, NAME, TAG id: branch_name run: | echo "SOURCE_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT @@ -61,7 +61,7 @@ jobs: env: PR: ${{ steps.findPr.outputs.pr }} with: - name: grafana-kiosk-${{env.PR}}.zip + name: grafana-kiosk-pr-${{env.PR}} path: bin overwrite: true retention-days: 7