Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions hydra-gates/scripts/lib/test_gate_glob_recursion_fixtures.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ GATES="${SCRIPT_DIR}/../run-hydra-gates.sh"
FIXTURE="$(cd "${SCRIPT_DIR}/../test-fixtures/glob-recursion" && pwd)"

_fails=0
LOG_DIR="/tmp"

_assert_found() { # <log-name> <expected-substring> <label>
local want="$2" label="$3" log
Expand All @@ -43,9 +44,10 @@ _assert_found() { # <log-name> <expected-substring> <label>
# The paths are gate-name-derived and contain no whitespace, so SC2012's
# concern (non-alphanumeric filenames) does not apply.
# shellcheck disable=SC2012
log="$(ls -t "/tmp/hydra-gate-$1.log" /tmp/hydra-gate-"$1".*.log 2>/dev/null | head -1)"
log="$(ls -t "${LOG_DIR}/hydra-gate-$1.log" "${LOG_DIR}"/hydra-gate-"$1".*.log \
"/tmp/hydra-gate-$1.log" /tmp/hydra-gate-"$1".*.log 2>/dev/null | head -1)"
if [ -z "${log}" ] || [ ! -f "${log}" ]; then
echo "FAIL: ${label} — no /tmp/hydra-gate-$1[.XXXXXX].log written (gate did not run)"
echo "FAIL: ${label} — no hydra-gate-$1[.XXXXXX].log in ${LOG_DIR} (gate did not run)"
_fails=$((_fails + 1)); return
fi
if grep -qF -- "${want}" "${log}"; then
Expand Down Expand Up @@ -82,6 +84,22 @@ echo "=== running real gates against ${FIXTURE} ==="
rm -f /tmp/hydra-gate-*.log
bash "${GATES}" "${FIXTURE}" > /tmp/hydra-glob-recursion-fixture.out 2>&1 || true

# WHERE THE LOGS ARE IS THE RUNNER'S TO SAY, NOT THIS TEST'S TO ASSUME.
#
# This suite looked in /tmp/hydra-gate-<name>.log. The runner writes to
# ${HYDRA_GATE_LOG_DIR}, which defaults to a mktemp directory so parallel runs
# across repos cannot clobber each other — and announces it on its first line.
# So every assertion below reported "gate did not run" for gates that had run
# and had written their findings, which is the worse of the two failure modes
# this file's own `_assert_found` comment warns about.
#
# Read the announced directory. The /tmp fallback in `_assert_found` keeps an
# older runner, which did use the fixed path, working unchanged.
LOG_DIR="$(sed -n 's/^\[hydra-gates\] findings logs: //p' \
/tmp/hydra-glob-recursion-fixture.out | head -1)"
LOG_DIR="${LOG_DIR:-/tmp}"
echo "reading findings from: ${LOG_DIR}"

echo
echo "=== nested-reach assertions ==="
_assert_found unsafe-auth-resolver \
Expand Down
13 changes: 13 additions & 0 deletions hydra-gates/scripts/test-fixtures/glob-recursion/appinfo/info.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<id>globrecfx</id>
<name>Glob Recursion Fixture</name>
<summary>Fixture app for the glob-recursion regression suite. Not a real app.</summary>
<description>Every defect in this app sits BELOW the directory a non-recursive glob would enumerate. There are deliberately no top-level twins, so a gate that re-acquires a shallow glob finds nothing and the suite fails.</description>
<version>1.0.0</version>
<licence>agpl</licence>
<author>Conduction</author>
<namespace>GlobRecFx</namespace>
<category>tools</category>
<dependencies><nextcloud min-version="30" max-version="32"/></dependencies>
</info>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
// SPDX-License-Identifier: EUPL-1.2
//
// Routed so the controller gates treat NestedThingController as a reachable
// endpoint rather than dead code. The controller sits at lib/Controller/Api/V1/,
// which is the depth this fixture exists to reach.
return [
'routes' => [
['name' => 'nestedThing#show', 'url' => '/api/v1/things/{id}', 'verb' => 'GET'],
['name' => 'nestedThing#adminState', 'url' => '/api/v1/admin-state', 'verb' => 'GET'],
],
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* Nested stub job.
*
* @license EUPL-1.2
* @copyright 2026 Conduction B.V.
*/

namespace OCA\GlobRecFx\BackgroundJob\Nested;

use OCP\BackgroundJob\TimedJob;

/**
* A scheduled job whose run() does nothing, two directories down.
*
* It is registered, it fires, and it has no effect. gate-3's subject.
*/
class NestedStubJob extends TimedJob
{


/**
* Runs the job.
*
* @param mixed $argument The job argument.
*
* @return void
*/
protected function run($argument): void
{
// In a complete implementation this would reconcile the nested
// objects. Nothing happens here.

}//end run()


}//end class
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php
/**
* Nested thing controller.
*
* @license EUPL-1.2
* @copyright 2026 Conduction B.V.
*/

namespace OCA\GlobRecFx\Controller\Api\V1;

use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\JSONResponse;

/**
* Carries two defects at once, three directories below lib/Controller/.
*/
class NestedThingController extends Controller
{


/**
* Reads one object by id, for any authenticated user, with no guard.
*
* The classic IDOR: the id comes from the request and nothing checks that
* the acting user may see it. gate-7's subject.
*
* @NoAdminRequired
*
* @param string $id The object id, straight from the URL.
*
* @return JSONResponse
*/
public function show(string $id): JSONResponse
{
return new JSONResponse(['id' => $id, 'secret' => 'exposed']);

}//end show()


/**
* Reads admin state behind an annotation that contradicts the body.
*
* The attribute says any authenticated user; the body requires an admin.
* gate-9's subject: the mismatch, not either half alone.
*
* @NoAdminRequired
*
* @return JSONResponse
*/
public function adminState(): JSONResponse
{
$this->requireAdmin();
return new JSONResponse(['state' => 'ok']);

}//end adminState()


}//end class
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* Nested orphan handler.
*
* @license EUPL-1.2
* @copyright 2026 Conduction B.V.
*/

namespace OCA\GlobRecFx\Service\Object;

/**
* One access-control predicate that nothing calls, at depth.
*
* A defined-but-uncalled authorisation method is identical to having no check
* at all (OWASP A01:2021). gate-6 finds it only if it opens this file.
*/
class NestedOrphanHandler
{


/**
* Decides whether a user may move a record into a state.
*
* @param string $userId The acting user.
* @param string $state The target state.
*
* @return boolean
*/
public function isTransitionAllowed(string $userId, string $state): bool
{
return ($userId !== '' && $state !== '');

}//end isTransitionAllowed()


}//end class
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
/**
* Permission handler.
*
* @license EUPL-1.2
* @copyright 2026 Conduction B.V.
*/

namespace OCA\GlobRecFx\Service\Object;

/**
* The real CWE-863 shape gate-8 missed for months in openregister, at the
* depth it missed it: lib/Service/Object/, one level below the directory a
* non-recursive `lib/Service/*.php` glob enumerates.
*/
class PermissionHandler
{


/**
* Resolves the authorization service.
*
* Fails open: an unavailable service is indistinguishable from an allowed
* action once the caller treats null as "no check to run".
*
* @return object|null
*/
private function getAuthorizationService(): ?object
{
try {
return \OC::$server->get('OCA\\GlobRecFx\\Service\\AuthorizationService');
} catch (\Throwable) {
return null;
}

}//end getAuthorizationService()


/**
* Decides whether the acting user may write the object.
*
* @param string $userId The acting user.
* @param string $objectId The object.
*
* @return boolean
*/
public function mayWrite(string $userId, string $objectId): bool
{
$auth = $this->getAuthorizationService();
if ($auth !== null) {
return $auth->check($userId, $objectId);
}

return true;

}//end mayWrite()


}//end class
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"openapi": "3.0.0",
"info": {
"title": "Glob Recursion Fixture \u2014 nested notification fragment",
"version": "1.0.0"
},
"components": {
"schemas": {
"Thing": {
"title": "Thing",
"type": "object",
"x-openregister-notifications": {
"onIntakeClosed": {
"trigger": {
"lifecycleEnter": "closed"
},
"channels": [
"mail"
],
"recipients": [
"owner"
],
"subject": {
"en": "Intake closed"
}
},
"onScoreChanged": {
"trigger": {
"type": "propertyChange",
"property": "score"
},
"channel": "mail",
"recipients": [
"owner"
],
"subject": {
"en": "Score changed"
}
}
},
"x-openregister-aggregations": {
"openIntakes": {
"filter": {
"@self.register": "things",
"status": "open"
},
"operation": "count"
}
},
"properties": {
"governanceBody": {
"type": "string"
},
"closedAt": {
"type": "string",
"format": "date-time",
"title": "Closed at"
},
"channel": {
"type": "string",
"title": "Channel",
"description": "The delivery channel this thing was received on."
},
"label": {
"type": "string",
"title": "Label",
"description": "The human-readable name of this thing."
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!-- SPDX-License-Identifier: EUPL-1.2 -->
<template>
<!--
A bespoke shell five directories down, past the -maxdepth 4 that gate-38
used to stop at. The root is a plain <div>, not the shared app root and
not a Nextcloud content wrapper, and it offers no jump-to-content
affordance.

The words the gate looks for appear nowhere in this file, including in
this comment: a fixture that quotes the pattern it is meant to defeat
defeats itself instead.
-->
<div class="nested-root">
<nav class="nested-root__nav">
<a href="/apps/globrecfx/things">Things</a>
</nav>
<main class="nested-root__main">
<router-view />
</main>
</div>
</template>

<script>
export default {
name: 'NestedRoot',
}
</script>
14 changes: 9 additions & 5 deletions hydra-gates/tests/run-helper-suites.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,22 @@ PKG_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")/.." && pwd)"
LIB="${PKG_ROOT}/scripts/lib"

# --- quarantine: "<basename>|<reason>" --------------------------------------
# These two fail for the SAME reason the crossref suite did — they reference
# This one fails for the SAME reason the crossref suite did — it references
# fixture directories that have never existed in this repository:
# scripts/test-fixtures/register-handler-resolution-{pass,fail}/
# scripts/test-fixtures/orphaned-write-capability-{pass,fail}/
# scripts/test-fixtures/orphaned-write-crossapp/
# (+ the glob-recursion fixture tree)
# test_gate_orphaned_capability_fixtures.sh is the worse of the two: its `cd`
# into the missing directory fails, the gate then finds nothing, and its
# test_gate_orphaned_capability_fixtures.sh is the worse shape: its `cd` into
# the missing directory fails, the gate then finds nothing, and its
# "pass fixture: 0 finding(s)" assertions report PASS on that empty result —
# green because the input is absent. Tracked, not silently unrun.
#
# `test_gate_glob_recursion_fixtures.sh` LEFT THE QUARANTINE 2026-09-08: its
# fixture tree is authored (scripts/test-fixtures/glob-recursion/) and all 7
# assertions pass. The quarantine's own integrity check is what required this
# line to go — a quarantined suite that passes is a hard failure, so a fixed
# suite cannot be left sitting on the list.
QUARANTINE=(
"test_gate_glob_recursion_fixtures.sh|fixtures absent — 7 assertions red; needs the nested lib/ + src/ fixture tree authored (follow-up to the gate-30 fixture work)"
"test_gate_orphaned_capability_fixtures.sh|fixtures absent — 3 assertions red AND 2 green-because-empty; needs register-handler-resolution-{pass,fail}, orphaned-write-capability-{pass,fail}, orphaned-write-crossapp authored"
)

Expand Down
Loading