skulpturenz / shared-resources

MIT License
0 stars 0 forks source link

v0.0.6 #253

Closed nmathew98 closed 1 week ago

github-actions[bot] commented 1 week ago

Title

v0.0.6


PR Type

Enhancement, Bug fix, Tests


Description


Changes walkthrough ๐Ÿ“

Relevant files
Enhancement
7 files
i18n.ts
Refactor i18n setup using i18nBuilder for login theme       

authnz-theme/src/keycloak-theme/login/i18n.ts
  • Replaced createUseI18n with i18nBuilder.
  • Added custom translations using withCustomTranslations.
  • Built the i18n configuration with build().
  • +630/-612
    WebauthnAuthenticate.tsx
    Refactor WebauthnAuthenticate with useScript hook               

    authnz-theme/src/keycloak-theme/login/pages/WebauthnAuthenticate.tsx
  • Removed inline script tags and related logic.
  • Introduced useScript hook for script management.
  • Updated element IDs for better specificity.
  • +16/-133
    WebauthnRegister.tsx
    Refactor WebauthnRegister with useInitialize hook               

    authnz-theme/src/keycloak-theme/login/pages/WebauthnRegister.tsx
  • Removed inline script tags and related logic.
  • Added useInitialize hook for initialization.
  • Conditional rendering based on readiness.
  • +6/-189 
    Template.tsx
    Simplify Template component with useInitialize hook           

    authnz-theme/src/keycloak-theme/login/Template.tsx
  • Removed script and link tag insertion logic.
  • Added useInitialize hook for initialization.
  • Simplified localization options handling.
  • +21/-111
    main.tsx
    Simplify main entry point with direct KcPage rendering     

    authnz-theme/src/main.tsx
  • Removed lazy loading of theme pages.
  • Simplified rendering logic with KcPage.
  • +7/-29   
    kryptos.go
    Use ordered map for environment variables in Kryptos         

    kryptos/kryptos/kryptos.go
  • Added orderedmap for environment variable management.
  • Replaced map with orderedmap for ENVS.
  • Updated SQL queries to include ORDER BY.
  • +26/-15 
    main.go
    Add interactive prompts for environment variables               

    kryptos/main.go
  • Added prompts for environment variables using promptui.
  • Set environment variables based on user input.
  • +61/-1   
    Tests
    1 files
    cat_set_test.go
    Add sorting test for environment keys in cat_set_test       

    kryptos/commands/cat_set_test.go
  • Added sorting test for environment keys.
  • Updated test keys for consistency.
  • +18/-2   
    Dependencies
    1 files
    package.json
    Update dependencies and package manager version                   

    authnz-theme/package.json
  • Updated multiple dependencies to newer versions.
  • Updated packageManager to a newer version.
  • +43/-43 
    Configuration changes
    4 files
    docker-compose.yml
    Update service replicas and healthcheck in docker-compose

    authnz/docker-compose.yml
  • Increased replicas for keycloak service.
  • Set replicas to 0 for several services.
  • Simplified healthcheck syntax.
  • +9/-37   
    docker-compose.proxy.yml
    Increase nginx replicas and update ulimits in proxy config

    authnz/docker-compose.proxy.yml
  • Increased replicas for nginx service.
  • Updated ulimits for nginx.
  • +3/-3     
    llm-review.yml
    Add GitHub Actions workflow for LLM review                             

    .github/workflows/llm-review.yml - Added new GitHub Actions workflow for LLM review.
    +28/-0   
    dependabot.yml
    Add Dependabot configuration for automated updates             

    .github/dependabot.yml - Added Dependabot configuration for dependency updates.
    +31/-0   
    Additional files (token-limit)
    27 files
    pnpm-lock.yaml
    ...                                                                                                           

    authnz-theme/pnpm-lock.yaml ...
    +2366/-4979
    go.sum
    ...                                                                                                           

    kryptos/go.sum ...
    +83/-56 
    go.sum
    ...                                                                                                           

    infrastructure/go.sum ...
    +40/-40 
    go.sum
    ...                                                                                                           

    authnz/go.sum ...
    +34/-36 
    go.sum
    ...                                                                                                           

    rollout/go.sum ...
    +34/-36 
    go.sum
    ...                                                                                                           

    telemetry/go.sum ...
    +34/-36 
    go.mod
    ...                                                                                                           

    infrastructure/go.mod ...
    +16/-18 
    go.mod
    ...                                                                                                           

    kryptos/go.mod ...
    +18/-16 
    docker-compose.yml
    ...                                                                                                           

    rollout/docker-compose.yml ...
    +9/-37   
    go.mod
    ...                                                                                                           

    authnz/go.mod ...
    +13/-16 
    go.mod
    ...                                                                                                           

    rollout/go.mod ...
    +13/-16 
    go.mod
    ...                                                                                                           

    telemetry/go.mod ...
    +13/-16 
    docker-compose.yml
    ...                                                                                                           

    telemetry/docker-compose.yml ...
    +6/-27   
    deploy-services.yml
    ...                                                                                                           

    .github/workflows/deploy-services.yml ...
    +5/-14   
    Dockerfile
    ...                                                                                                           

    authnz/keycloak/Dockerfile ...
    +9/-9     
    llm-review.yml
    ...                                                                                                           

    .github/workflows/llm-review.yml ...
    +28/-0   
    dependabot.yml
    ...                                                                                                           

    .github/dependabot.yml ...
    +31/-0   
    docker-compose.proxy.yml
    ...                                                                                                           

    rollout/docker-compose.proxy.yml ...
    +3/-3     
    docker-compose.proxy.yml
    ...                                                                                                           

    telemetry/docker-compose.proxy.yml ...
    +3/-3     
    docker-compose.logs.yml
    ...                                                                                                           

    telemetry/docker-compose.logs.yml ...
    +2/-9     
    Dockerfile
    ...                                                                                                           

    authnz/.devcontainer/Dockerfile ...
    +1/-1     
    nginx.conf
    ...                                                                                                           

    authnz/nginx/nginx.conf ...
    +1/-1     
    Dockerfile
    ...                                                                                                           

    kryptos/.devcontainer/Dockerfile ...
    +1/-1     
    Dockerfile
    ...                                                                                                           

    infrastructure/.devcontainer/Dockerfile ...
    +1/-1     
    Dockerfile
    ...                                                                                                           

    rollout/.devcontainer/Dockerfile ...
    +1/-1     
    Dockerfile
    ...                                                                                                           

    telemetry/.devcontainer/Dockerfile ...
    +1/-1     
    Dockerfile
    ...                                                                                                           

    authnz-theme/.devcontainer/Dockerfile ...
    +1/-1     

    ๐Ÿ’ก PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    github-actions[bot] commented 1 week ago

    PR Reviewer Guide ๐Ÿ”

    Here are some key observations to aid the review process:

    โฑ๏ธ Estimated effort to review: 4 ๐Ÿ”ต๐Ÿ”ต๐Ÿ”ต๐Ÿ”ตโšช
    ๐Ÿ… Score: 85
    ๐Ÿงช PR contains tests
    ๐Ÿ”’ No security concerns identified
    โšก Recommended focus areas for review

    Code Smell
    The new code introduces a large number of hardcoded strings for translations. Consider externalizing these strings to a separate localization file or using a more scalable approach for managing translations. Code Complexity
    The new implementation of the Webauthn authentication process has increased complexity. Ensure that the new script handling is well-documented and tested to avoid potential issues. Code Complexity
    Similar to WebauthnAuthenticate, the new Webauthn registration process has increased complexity. Review the changes to ensure they are maintainable and well-tested.
    github-actions[bot] commented 1 week ago

    :tropical_drink: preview on network/skulpture/shared-infrastructure

    Pulumi report
    Previewing update (shared-infrastructure)
    
    View Live: https://app.pulumi.com/skulpture/network/shared-infrastructure/previews/dedde3ae-5c38-42aa-b16b-6d948dd3a590
    
    @ Previewing update......
    Downloading plugin gcp-7.38.0: starting
    Downloading plugin digitalocean-4.34.0: starting
    Downloading plugin digitalocean-4.34.0: done
    Installing plugin digitalocean-4.34.0: starting
    Downloading plugin gcp-7.38.0: done
    Installing plugin gcp-7.38.0: starting
    Installing plugin digitalocean-4.34.0: done
    @ Previewing update....
    Installing plugin gcp-7.38.0: done
    
    @ Previewing update.....................................................................
    pulumi:pulumi:Stack network-shared-infrastructure running 
    @ Previewing update....
    pulumi:pulumi:Stack network-shared-infrastructure  
    Resources:
    12 unchanged
    
    
    github-actions[bot] commented 1 week ago

    :tropical_drink: preview on rollout/skulpture/shared-rollout

    Pulumi report
    Previewing update (shared-rollout)
    
    View Live: https://app.pulumi.com/skulpture/rollout/shared-rollout/previews/be39173c-f193-4f6e-bed3-7e9b39dffc78
    
    @ Previewing update.....
    Downloading plugin gcp-7.38.0: starting
    Downloading plugin cloudflare-5.42.0: starting
    Downloading plugin cloudflare-5.42.0: done
    Downloading plugin gcp-7.38.0: done
    Installing plugin cloudflare-5.42.0: starting
    Installing plugin gcp-7.38.0: starting
    @ Previewing update....
    Installing plugin cloudflare-5.42.0: done
    Installing plugin gcp-7.38.0: done
    @ Previewing update....
    
    @ Previewing update............................................................................
    pulumi:pulumi:Stack rollout-shared-rollout running 
    @ Previewing update....
    pulumi:pulumi:Stack rollout-shared-rollout  
    Resources:
    4 unchanged
    
    
    github-actions[bot] commented 1 week ago

    PR Code Suggestions โœจ

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Security
    Ensure proper handling of inputs in kcSanitize to prevent XSS vulnerabilities ___ **Ensure that kcSanitize is properly handling all potential inputs to avoid XSS
    vulnerabilities.** [authnz-theme/src/keycloak-theme/account/pages/Totp.tsx [231]](https://github.com/skulpturenz/shared-resources/pull/253/files#diff-30a1dcec826317d83dbf2330892881ad9b45e5d3a6651bfb0e4b0403176a3d38R231-R231) ```diff + __html: kcSanitize( -+ messagesPerField.get( -+ "totp", -+ ), ++ messagesPerField.get("totp") || "", + ), ```
    Suggestion importance[1-10]: 9 Why: This suggestion is critical as it addresses potential XSS vulnerabilities by ensuring that `kcSanitize` handles undefined inputs properly, which is essential for security.
    9
    Ensure that sanitization effectively mitigates XSS risks ___ **Validate that kcSanitize properly handles all potential HTML inputs to prevent XSS
    vulnerabilities.** [authnz-theme/src/keycloak-theme/login/pages/LoginRecoveryAuthnCodeConfig.tsx [150]](https://github.com/skulpturenz/shared-resources/pull/253/files#diff-a185440648eb7f02a590c52dcf7b989cf361ba58d62007b2be53746a3fe85a8bR150-R150) ```diff ++ __html: kcSanitize(recoveryCodeListHTML ?? ""), - ```
    Suggestion importance[1-10]: 6 Why: This suggestion highlights a security concern regarding XSS vulnerabilities, which is important, but it does not propose a specific code change.
    6
    Possible issue
    Validate that enabledLanguages is not empty before mapping to prevent errors ___ **Validate that enabledLanguages is not empty before mapping to avoid potential
    runtime errors.** [authnz-theme/src/keycloak-theme/account/Template.tsx [64-66]](https://github.com/skulpturenz/shared-resources/pull/253/files#diff-00f5cd81dabbdd07d5136ab5dc11513362372803f713d8d109c1a8c7261aaf6cR64-R66) ```diff + const localizationOptions = -+ enabledLanguages.map(locale => ({ ++ enabledLanguages.length > 0 ? enabledLanguages.map(locale => ({ + value: locale.label, + label: locale.label, + href: locale.href, -+ })) ?? []; ++ })) : []; ```
    Suggestion importance[1-10]: 8 Why: This suggestion addresses a potential runtime error by ensuring that `enabledLanguages` is checked before mapping, which is a good practice for avoiding issues when the array is empty.
    8
    Ensure that messagesPerField contains expected keys to avoid undefined access ___ **Check that the messagesPerField map contains the expected keys to prevent accessing
    undefined values.** [authnz-theme/src/keycloak-theme/account/pages/Totp.tsx [288]](https://github.com/skulpturenz/shared-resources/pull/253/files#diff-30a1dcec826317d83dbf2330892881ad9b45e5d3a6651bfb0e4b0403176a3d38R288-R288) ```diff + __html: kcSanitize( -+ messagesPerField.get( -+ "userLabel", -+ ), ++ messagesPerField.get("userLabel") || "", + ), ```
    Suggestion importance[1-10]: 7 Why: This suggestion is relevant as it highlights the need to check for expected keys in `messagesPerField`, which can prevent runtime errors. However, it could be improved by specifying which keys should be checked.
    7
    Ensure all necessary translation keys are defined to prevent runtime errors ___ **Ensure that the translations provided cover all necessary keys to avoid runtime
    errors when accessing undefined properties.** [authnz-theme/src/keycloak-theme/account/i18n.ts [6-22]](https://github.com/skulpturenz/shared-resources/pull/253/files#diff-f647648cf4f6bb7c56cc73df5f93be312bbda30dad62adc74666b0915684e071R6-R22) ```diff + withCustomTranslations({ + en: { + lightTheme: "Light", + darkTheme: "Dark", + systemTheme: "System", + switchTo: "Switch to", + toggleTheme: "Toggle theme", + selectLanguage: "Select language...", + searchLanguage: "Search language...", + noLanguages: "No language found", + hidePassword: "Hide password", + showPassword: "Show password", -+ // Modified base + backToApplication: "Back to application", ++ // Ensure all necessary keys are defined ++ // Add any missing keys here + }, + }) ```
    Suggestion importance[1-10]: 5 Why: The suggestion highlights the importance of ensuring all translation keys are defined, which can prevent runtime errors. However, it lacks specificity on which keys might be missing.
    5
    Ensure the condition accurately checks for the presence of social providers ___ **Confirm that the condition realm.password && social?.providers?.length correctly
    checks for the existence of providers.** [authnz-theme/src/keycloak-theme/login/pages/Login.tsx [100]](https://github.com/skulpturenz/shared-resources/pull/253/files#diff-ef8eadc525b8939da4cb654c5a1d1ef3a6d38ba38f26b510720933c91cc12b1eR100-R100) ```diff -+ {realm.password && social?.providers?.length && ( ++ {realm.password && social && social.providers?.length > 0 && ( ```
    Suggestion importance[1-10]: 5 Why: The suggestion improves the condition to check for social providers more accurately, which is relevant but not critical.
    5
    Verify that all required translation keys are included for completeness ___ **Ensure that the translations provided in the withCustomTranslations method are
    complete and do not miss any necessary keys for other languages.** [authnz-theme/src/keycloak-theme/login/i18n.ts [5-6]](https://github.com/skulpturenz/shared-resources/pull/253/files#diff-105df81b420322681ad363ea841c68c22996948e0aee79f067b161a66b534951R5-R6) ```diff + .withCustomTranslations({ + en: { ++ // Ensure all necessary keys are included for translations ```
    Suggestion importance[1-10]: 3 Why: The suggestion addresses completeness in translations but lacks specificity on which keys are missing, making it a minor improvement.
    3
    Possible bug
    Add error handling for missing keys in the environment variable map ___ **Handle the case where command.Key does not exist in kryptos.ENVS to avoid potential
    nil dereference.** [kryptos/commands/grep.go [16]](https://github.com/skulpturenz/shared-resources/pull/253/files#diff-5c07349cdd4b74f2e0afc03e5de55ed862eb4d8a3b2ab561e7d37077d177a48bR16-R16) ```diff -value, ok := kryptos.ENVS.Get(command.Key) +value, ok := kryptos.ENVS.Get(command.Key); if !ok { return fmt.Errorf("key not found") } ```
    Suggestion importance[1-10]: 8 Why: This suggestion addresses a potential nil dereference issue, which is critical for the stability of the application. Proper error handling is essential.
    8
    Ensure that the value passed to sanitization is always a valid string ___ **Check that messagesPerField.get("termsAccepted") returns a valid string before
    passing it to kcSanitize.** [authnz-theme/src/keycloak-theme/login/pages/Register.tsx [182-183]](https://github.com/skulpturenz/shared-resources/pull/253/files#diff-c18f6774f6bc3f2f2570dce7a684a25f90422fb4046224a333afbfd5f2c2bde7R182-R183) ```diff -+ messagesPerField.get("termsAccepted"), ++ messagesPerField.get("termsAccepted") || "", ```
    Suggestion importance[1-10]: 7 Why: This suggestion improves robustness by ensuring that a valid string is passed to the sanitization function, which is a good practice.
    7
    Ensure proper initialization of the environment variable map to avoid runtime errors ___ **Ensure that the ENVS variable is initialized before use to prevent nil pointer
    dereference.** [kryptos/kryptos/kryptos.go [16]](https://github.com/skulpturenz/shared-resources/pull/253/files#diff-52d822dfcf5c61ba100975219c933d7bf9d7eb252bc0bbd2c88c408bb68855edR16-R16) ```diff -var ENVS = orderedmap.NewOrderedMap[string, string]() +var ENVS *orderedmap.OrderedMap[string, string] = orderedmap.NewOrderedMap[string, string]() ```
    Suggestion importance[1-10]: 7 Why: The suggestion improves the safety of the code by ensuring that the `ENVS` variable is correctly initialized, which can prevent runtime errors.
    7
    Best practice
    Improve uniqueness of the authentication button ID to prevent conflicts ___ **Ensure that the authButtonId is unique across the entire application to avoid
    potential conflicts.** [authnz-theme/src/keycloak-theme/login/pages/WebauthnAuthenticate.tsx [29]](https://github.com/skulpturenz/shared-resources/pull/253/files#diff-9a0c86f51c036c183f4ff5ecfd6158df01a9123e16783ece152f288a05635e81R29-R29) ```diff -const authButtonId = "authenticateWebAuthnButton"; +const authButtonId = `authenticateWebAuthnButton-${uniqueIdentifier}`; ```
    Suggestion importance[1-10]: 6 Why: While ensuring the uniqueness of IDs is a good practice, the suggestion lacks context on how to generate the `uniqueIdentifier`, making it less actionable.
    6
    Performance
    Optimize output writing by using a buffered writer for better performance ___ **Consider using a buffered writer for command.View to improve performance when
    writing multiple lines.** [kryptos/commands/cat.go [16]](https://github.com/skulpturenz/shared-resources/pull/253/files#diff-96f1cde39b6d3133c8e2369e4552a6a5f25b069fe840411a54e563cb7a14c85aR16-R16) ```diff -_, err := fmt.Fprintf(command.View, "%s=%s\n", key, value) +writer := bufio.NewWriter(command.View); _, err := writer.WriteString(fmt.Sprintf("%s=%s\n", key, value)); writer.Flush() ```
    Suggestion importance[1-10]: 5 Why: While using a buffered writer can improve performance, the actual performance gain may be minimal in this context, making it a lower priority change.
    5
    github-actions[bot] commented 1 week ago

    :tropical_drink: preview on telemetry/skulpture/shared-telemetry

    Pulumi report
    Previewing update (shared-telemetry)
    
    View Live: https://app.pulumi.com/skulpture/telemetry/shared-telemetry/previews/b861fcb2-d9fb-42a7-8dcb-80d6bb059723
    
    @ Previewing update.....
    Downloading plugin cloudflare-5.42.0: starting
    Downloading plugin gcp-7.38.0: starting
    Downloading plugin cloudflare-5.42.0: done
    Installing plugin cloudflare-5.42.0: starting
    Downloading plugin gcp-7.38.0: done
    Installing plugin gcp-7.38.0: starting
    @ Previewing update....
    Installing plugin cloudflare-5.42.0: done
    Installing plugin gcp-7.38.0: done
    
    @ Previewing update..........................................................................
    pulumi:pulumi:Stack telemetry-shared-telemetry running 
    @ Previewing update....
    pulumi:pulumi:Stack telemetry-shared-telemetry  
    Resources:
    4 unchanged
    
    
    github-actions[bot] commented 1 week ago

    :tropical_drink: preview on authnz/skulpture/shared-authnz

    Pulumi report
    Previewing update (shared-authnz)
    
    View Live: https://app.pulumi.com/skulpture/authnz/shared-authnz/previews/6b1b4ddd-b154-4b73-8863-ff0619150381
    
    @ Previewing update......
    Downloading plugin gcp-7.38.0: starting
    Downloading plugin cloudflare-5.42.0: starting
    Downloading plugin cloudflare-5.42.0: done
    Downloading plugin gcp-7.38.0: done
    Installing plugin cloudflare-5.42.0: starting
    Installing plugin gcp-7.38.0: starting
    Installing plugin cloudflare-5.42.0: done
    @ Previewing update....
    Installing plugin gcp-7.38.0: done
    
    @ Previewing update..........................................................................
    pulumi:pulumi:Stack authnz-shared-authnz running 
    @ Previewing update....
    pulumi:pulumi:Stack authnz-shared-authnz  
    Resources:
    4 unchanged
    
    
    nmathew98 commented 1 week ago
    CREATE COLLATION nocase (
          provider = icu,
          locale = 'en-US',
          deterministic = false
        );