mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-11-17 17:44:09 +01:00
Merge remote-tracking branch 'origin/main' into integrate/source-errors
# Conflicts: # public/asset-manifest.json # public/css/all.min.css # public/css/style.css # public/partials/anonymize.htm # public/script/vendor.min.js
This commit is contained in:
commit
c014b3c8cf
22 files changed
+444
-92
No files matched your search
@@ -55,6 +55,13 @@ before="$(image_id "$IMAGE")"
|
||||
docker compose build anonymous_github
|
||||
after="$(image_id "$IMAGE")"
|
||||
|
||||
# Validate replacement configuration before stopping any working container.
|
||||
# A healthy HTTP endpoint does not prove that the GitHub App key is mounted.
|
||||
for service in anonymous_github streamer; do
|
||||
log "Checking GitHub App configuration in ${service}"
|
||||
docker compose run --rm --no-deps --entrypoint node "$service" ./build/scripts/check-github-app-key.js
|
||||
done
|
||||
|
||||
if [[ $legacy_alerts == 1 ]]; then
|
||||
protocol="$(docker image inspect -f '{{index .Config.Labels "science.4open.owner-alert-protocol"}}' "$IMAGE")"
|
||||
[[ $protocol == recipient-v2 ]] || { warn "replacement image lacks recipient alert migration support"; exit 1; }
|
||||
|
||||
@@ -996,6 +996,14 @@ app.get("/api/admin/users/:username", (req, res) => {
|
||||
});
|
||||
app.post("/api/admin/users/:username/ban", (req, res) => res.json({ ok: true, reposQueued: 2 }));
|
||||
app.post("/api/admin/users/:username/:action", ok);
|
||||
app.get("/api/user/repository_picker", (req, res) => {
|
||||
const cursor = Number(req.query.cursor || 0);
|
||||
const query = String(req.query.q || "").toLowerCase();
|
||||
const repos = Array.from({ length: 63 }, (_, id) => ({ id, fullName: `research/project-${String(id + 1).padStart(2, "0")}` }));
|
||||
const matches = repos.filter(repo => repo.fullName.toLowerCase().includes(query));
|
||||
res.json({ items: matches.slice(cursor, cursor + 20), nextCursor: cursor + 20 < matches.length ? cursor + 20 : null });
|
||||
});
|
||||
|
||||
app.get("/api/user/:username/all_repositories", (req, res) => {
|
||||
const u = adminUsers.find((x) => x.username === req.params.username) || adminUsers[0];
|
||||
res.json(githubRepos(u));
|
||||
|
||||
+20
-1
@@ -45,12 +45,15 @@ with tempfile.TemporaryDirectory(prefix=PROJECT) as temp:
|
||||
log = docker / 'fixture/fixture-json.log'
|
||||
log.touch()
|
||||
edge = nginx / 'anonymous.access.json'
|
||||
reader_gid = os.getgid() if os.getgid() != 0 else 65534
|
||||
edge.touch()
|
||||
if os.getuid() == 0: os.chown(edge, 65534, reader_gid)
|
||||
edge.chmod(0o640) # root without DAC capabilities needs the supplementary group
|
||||
password = temp / 'password'
|
||||
password.write_text(secrets.token_urlsafe(32))
|
||||
password.chmod(0o644) # temp directory is 0700; Grafana uid must read the bind mount
|
||||
env = {**os.environ, 'GRAFANA_ADMIN_USER': 'local-test', 'GRAFANA_PASSWORD_FILE': str(password),
|
||||
'DOCKER_LOG_DIR': str(docker), 'NGINX_LOG_DIR': str(nginx), 'GRAFANA_PORT': '0'}
|
||||
'NGINX_LOG_GID': str(reader_gid), 'DOCKER_LOG_DIR': str(docker), 'NGINX_LOG_DIR': str(nginx), 'GRAFANA_PORT': '0'}
|
||||
override = temp / 'override.yml'
|
||||
override.write_text(yaml.safe_dump({'services': {
|
||||
'victorialogs': {'ports': ['127.0.0.1::9428']},
|
||||
@@ -121,6 +124,22 @@ with tempfile.TemporaryDirectory(prefix=PROJECT) as temp:
|
||||
assert len(query('event:job_failed')) == 1
|
||||
assert all('requestId' not in r['_stream'] and 'instance' not in r['_stream'] for r in rows)
|
||||
print('PASS ingestion, privacy allowlist, malformed input, API/streamer/job/edge correlation')
|
||||
# Rename/create rotation must retain read access to both inodes.
|
||||
edge.rename(nginx / 'anonymous.access.json.1')
|
||||
edge.touch(); edge.chmod(0o640)
|
||||
if os.getuid() == 0: os.chown(edge, 65534, reader_gid)
|
||||
time.sleep(2) # discover the empty replacement before appending (read_from=end)
|
||||
rotation_id = str(uuid.uuid4())
|
||||
with edge.open('a') as out:
|
||||
out.write(json.dumps({'status': 502, 'request_time': 0.1,
|
||||
'app_request_id': rotation_id, 'route': '/api/repo/:id'}) + '\n')
|
||||
wait_for(lambda: len(query('requestId:="' + rotation_id + '"')) == 1)
|
||||
inspection = json.loads(run(['docker', 'inspect', compose('ps', '-q', 'vector')]))[0]
|
||||
assert str(reader_gid) in inspection['HostConfig']['GroupAdd']
|
||||
assert 'ALL' in inspection['HostConfig']['CapDrop']
|
||||
print('PASS restricted 0640 Nginx access and rename/create rotation with no capabilities')
|
||||
if os.environ.get('LOGGING_ACCESS_ONLY') == '1':
|
||||
sys.exit(0)
|
||||
# Query every shipped dashboard and alert expression against the real server.
|
||||
dashboard = json.loads((CONFIG / 'grafana/dashboards/operations.json').read_text())
|
||||
for panel in dashboard['panels']:
|
||||
|
||||
Reference in new issue
Block a user