URL parse check in deliver queue
ci/woodpecker/tag/ociImageTag Pipeline is running Details

This commit is contained in:
Natty 2024-01-08 02:07:12 +01:00
parent 6a66010294
commit e7ff3a81bb
Signed by: natty
GPG Key ID: BF6CB659ADEE60EC
1 changed files with 17 additions and 14 deletions

View File

@ -1,18 +1,14 @@
import { URL } from "node:url"; import {URL} from "node:url";
import request from "@/remote/activitypub/request.js"; import request from "@/remote/activitypub/request.js";
import { registerOrFetchInstanceDoc } from "@/services/register-or-fetch-instance-doc.js"; import {registerOrFetchInstanceDoc} from "@/services/register-or-fetch-instance-doc.js";
import Logger from "@/services/logger.js"; import Logger from "@/services/logger.js";
import { Instances } from "@/models/index.js"; import {Instances} from "@/models/index.js";
import { import {apRequestChart, federationChart, instanceChart,} from "@/services/chart/index.js";
apRequestChart, import {fetchInstanceMetadata} from "@/services/fetch-instance-metadata.js";
federationChart, import {toPuny} from "@/misc/convert-host.js";
instanceChart, import {StatusError} from "@/misc/fetch.js";
} from "@/services/chart/index.js"; import {shouldSkipInstance} from "@/misc/skipped-instances.js";
import { fetchInstanceMetadata } from "@/services/fetch-instance-metadata.js"; import type {DeliverJobData} from "@/queue/types.js";
import { toPuny } from "@/misc/convert-host.js";
import { StatusError } from "@/misc/fetch.js";
import { shouldSkipInstance } from "@/misc/skipped-instances.js";
import type { DeliverJobData } from "@/queue/types.js";
import type Bull from "bull"; import type Bull from "bull";
const logger = new Logger("deliver"); const logger = new Logger("deliver");
@ -20,7 +16,14 @@ const logger = new Logger("deliver");
let latest: string | null = null; let latest: string | null = null;
export default async (job: Bull.Job<DeliverJobData>) => { export default async (job: Bull.Job<DeliverJobData>) => {
const { host } = new URL(job.data.to); let host: string;
try {
host = new URL(job.data.to).host;
} catch (e) {
logger.error(`Failed URL parse: ${JSON.stringify(job.data)}`);
return "skip";
}
const puny = toPuny(host); const puny = toPuny(host);
if (await shouldSkipInstance(puny)) return "skip"; if (await shouldSkipInstance(puny)) return "skip";