Edits history of script submission #4698 for ' Search URL scans (cloudflare)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Cloudflare = {
      token: string;
      email: string;
      key: string;
    };
    /**
     * Search URL scans
     * Search scans by date and webpages' requests, including full URL (after redirects), hostname, and path.  A successful scan will appear in search results a few minutes after finishing but may take much longer if the system in under load. By default, only successfully completed scans will appear in search results, unless searching by `scanId`. Please take into account that older scans may be removed from the search index at an unspecified time.
     */
    export async function main(
      auth: Cloudflare,
      accountId: string,
      scanId: string | undefined,
      limit: string | undefined,
      next_cursor: string | undefined,
      date_start: string | undefined,
      date_end: string | undefined,
      url: string | undefined,
      hostname: string | undefined,
      path: string | undefined,
      page_url: string | undefined,
      page_hostname: string | undefined,
      page_path: string | undefined,
      account_scans: string | undefined
    ) {
      const url_ = new URL(
        `https://api.cloudflare.com/client/v4/accounts/${accountId}/urlscanner/scan`
      );
      for (const [k, v] of [
        ["scanId", scanId],
        ["limit", limit],
        ["next_cursor", next_cursor],
        ["date_start", date_start],
        ["date_end", date_end],
        ["url", url],
        ["hostname", hostname],
        ["path", path],
        ["page_url", page_url],
        ["page_hostname", page_hostname],
        ["page_path", page_path],
        ["account_scans", account_scans],
      ]) {
        if (v !== undefined && v !== "") {
          url_.searchParams.append(k, v);
        }
      }
      const response = await fetch(url_, {
        method: "GET",
        headers: {
          "X-AUTH-EMAIL": auth.email,
          "X-AUTH-KEY": auth.key,
          Authorization: "Bearer " + auth.token,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 383 days ago

  • nativets
    type Cloudflare = {
      token: string;
      email: string;
      key: string;
    };
    /**
     * Search URL scans
     * Search scans by date and webpages' requests, including full URL (after redirects), hostname, and path.  A successful scan will appear in search results a few minutes after finishing but may take much longer if the system in under load. By default, only successfully completed scans will appear in search results, unless searching by `scanId`. Please take into account that older scans may be removed from the search index at an unspecified time.
     */
    export async function main(
      auth: Cloudflare,
      accountId: string,
      scanId: string | undefined,
      limit: string | undefined,
      next_cursor: string | undefined,
      date_start: string | undefined,
      date_end: string | undefined,
      url: string | undefined,
      hostname: string | undefined,
      path: string | undefined,
      page_url: string | undefined,
      page_hostname: string | undefined,
      page_path: string | undefined,
      account_scans: string | undefined
    ) {
      const url_ = new URL(
        `https://api.cloudflare.com/client/v4/accounts/${accountId}/urlscanner/scan`
      );
      for (const [k, v] of [
        ["scanId", scanId],
        ["limit", limit],
        ["next_cursor", next_cursor],
        ["date_start", date_start],
        ["date_end", date_end],
        ["url", url],
        ["hostname", hostname],
        ["path", path],
        ["page_url", page_url],
        ["page_hostname", page_hostname],
        ["page_path", page_path],
        ["account_scans", account_scans],
      ]) {
        if (v !== undefined && v !== "") {
          url_.searchParams.append(k, v);
        }
      }
      const response = await fetch(url_, {
        method: "GET",
        headers: {
          "X-AUTH-EMAIL": auth.email,
          "X-AUTH-KEY": auth.key,
          Authorization: "Bearer " + auth.token,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 920 days ago