4 Commits
Author SHA1 Message Date
kevinveenbirkenbachandClaude Opus 5.5 c3a3eb307e test: autoescape the Semaphore env render and assert the once-flag control by value
PR 2488 turned red in lint-python and CodeQL on two test changes. test_external_auth_matching.py built a jinja2.Environment without autoescape (ruff S701, CodeQL Jinja2 templating with autoescape=False); it now passes autoescape=jinja2.select_autoescape(), which leaves the env.j2 render unescaped because the template name has no html or xml extension. test_once_flag_before_post_load.py compared with assertTrue(a == b) (CodeQL imprecise assert); it now uses assertEqual, so a failure prints the findings. Negative control: ruff check of the committed Semaphore test reports S701 at line 24, the new file passes. Tests: KIX and Semaphore unit tests plus the once-flag, comment and import lints, 35 passed, 20 subtests.

🎯 Fix: 95 %
💥 Break: 1 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 94
🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 %

Created-with: https://s.veen.world/skills
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 12:14:31 +00:00
kevinveenbirkenbachandClaude Opus 5.5 d5338d8da2 fix(web-app-semaphore): link an LDAP login to the user its OIDC login created
With OIDC and LDAP both enabled, the OIDC biber spec runs first and Semaphore v2.20.24 creates user biber with an OIDC identity. The LDAP login of the same person then authorizes (Semaphore log: User biber with email biber@main.infinito.test authorized via LDAP correctly) and fails on pq: duplicate key value violates unique constraint user_username_key, so the page answers 500 and test-login-ldap-biber.js:5 stays on the login page (semaphore#0 of push run 44939230779 behind the LDAP tab fix; same spec red in main run 44987966640). In the default auto mode, matchExternalUserByEmail in api/login_identity.go skips a user who already holds an external identity, so the second provider inserts the username again. env.j2 now renders SEMAPHORE_EXTERNAL_AUTH_EMAIL_MATCHING=always only when both providers are enabled. Semaphore never adopts a local account in any mode, OIDC matches by email only when email_verified is set, and Keycloak federates the same OpenLDAP, so both providers share one username space. test_external_auth_matching.py renders all four provider combinations; without the change the both-providers case fails. Tests: Semaphore unit tests plus the comment lint, 21 passed, 7 subtests.

🎯 Fix: 90 %
💥 Break: 4 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 86
🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 %

Created-with: https://s.veen.world/skills
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 10:49:16 +00:00
kevinveenbirkenbachandClaude Opus 5.5 326f063bd3 fix(codescan): clear the mechanical CodeQL notes and lint them away (WIP)
Work-in-progress commit on the collective code-scanning sidetree, so main
can be merged in; the single quality-high gate runs on the integration
branch before the pull request.

Fixes the CodeQL notes py/import-and-import-from, py/unused-import,
py/unused-global-variable, py/empty-except, py/mixed-tuple-returns and
py/unused-local-variable across 194 files, and adds one lint per rule under
tests/lint/repository/python/ so none of them can come back:
test_import_and_import_from, test_unused_imports_hidden_from_ruff,
test_unused_global_variables, test_empty_except, test_mixed_tuple_returns,
test_unused_local_variables, plus test_modules_import.

Accepted security finding: MEDUSA-MP-SCAN-2056 (low) on
utils/i18n/client.py:21, an import line matched by a keyword heuristic;
operator-confirmed false positive.

🎯 Fix: 85 %
💥 Break: 8 %
💸 Cost: –
⏱️ Time: –
🛡️ Security: 100 %
🏆 Score: 78
🚦 Gate: ⛔ fix 85 % < 90, break 8 % > 5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 18:44:29 +00:00
kevinveenbirkenbachandClaude Opus 5.5 8fdfa6ef51 feat(web-app-semaphore): sign in on the onion sibling as well as on clearnet
Semaphore v2.19.17 builds its post-login redirect from its one WebHost
(url.JoinPath(WebHost, return)), marks the session cookie Secure when
WebHost is https, and registered a single OIDC provider whose
redirect_url is clearnet. A login started on the onion sibling therefore
lost the oauthstate cookie at the clearnet callback and the session on
the plain-http onion origin: semaphore#0 of run 40625679270 failed five
login and design specs in PASS 2, where Playwright picked the .onion
sibling ("http: named cookie not present" 24 times in the container
log, while LDAP accepted the rotated credentials six times).

Semaphore keys OIDC providers by id from the URL path and gives each its
own redirect_url, so when the role has an onion sibling and SSO is on:

- a second provider keycloak_onion, same issuer, client and claims, with
  the onion sibling's plaintext redirect_url; Keycloak's redirect_uris
  lookup already registers http://<onion>/*;
- the onion vhost rewrites the absolute WebHost redirects to relative
  ones (proxy_redirect) and drops Secure from the semaphore cookie
  (proxy_cookie_flags), next to the existing base-href rewrite;
- location = /api/auth/login filters the provider list per vhost with
  sub_filter, so clearnet offers keycloak and the onion vhost
  keycloak_onion, both labelled as before; each dropped provider has a
  pattern for either list position because Semaphore does not fix the
  order.

Without an onion sibling the provider JSON and both proxy hooks render
exactly as before. test_onion_login renders the vars through Ansible's
templar for both cases; 16 of its 18 tests fail against the previous
files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 02:29:59 +01:00