Edits history of script submission #4628 for ' Get Top Attack Pairs (origin and target locations) By Layer 7 Attacks (cloudflare)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Cloudflare = {
      token: string;
      email: string;
      key: string;
    };
    /**
     * Get Top Attack Pairs (origin and target locations) By Layer 7 Attacks
     * Get the top attacks from origin to target location. Values are a percentage out of the total layer 7 attacks (with billing country). The attack magnitude can be defined by the number of mitigated requests or by the number of zones affected. You can optionally limit the number of attacks per origin/target location (useful if all the top attacks are from or to the same location).
     */
    export async function main(
      auth: Cloudflare,
      limit: string | undefined,
      name: string | undefined,
      dateRange: string | undefined,
      dateStart: string | undefined,
      dateEnd: string | undefined,
      asn: string | undefined,
      location: string | undefined,
      limitDirection: "ORIGIN" | "TARGET" | undefined,
      limitPerLocation: string | undefined,
      magnitude: "AFFECTED_ZONES" | "MITIGATED_REQUESTS" | undefined,
      format: "JSON" | "CSV" | undefined
    ) {
      const url = new URL(
        `https://api.cloudflare.com/client/v4/radar/attacks/layer7/top/attacks`
      );
      for (const [k, v] of [
        ["limit", limit],
        ["name", name],
        ["dateRange", dateRange],
        ["dateStart", dateStart],
        ["dateEnd", dateEnd],
        ["asn", asn],
        ["location", location],
        ["limitDirection", limitDirection],
        ["limitPerLocation", limitPerLocation],
        ["magnitude", magnitude],
        ["format", format],
      ]) {
        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;
    };
    /**
     * Get Top Attack Pairs (origin and target locations) By Layer 7 Attacks
     * Get the top attacks from origin to target location. Values are a percentage out of the total layer 7 attacks (with billing country). The attack magnitude can be defined by the number of mitigated requests or by the number of zones affected. You can optionally limit the number of attacks per origin/target location (useful if all the top attacks are from or to the same location).
     */
    export async function main(
      auth: Cloudflare,
      limit: string | undefined,
      name: string | undefined,
      dateRange: string | undefined,
      dateStart: string | undefined,
      dateEnd: string | undefined,
      asn: string | undefined,
      location: string | undefined,
      limitDirection: "ORIGIN" | "TARGET" | undefined,
      limitPerLocation: string | undefined,
      magnitude: "AFFECTED_ZONES" | "MITIGATED_REQUESTS" | undefined,
      format: "JSON" | "CSV" | undefined
    ) {
      const url = new URL(
        `https://api.cloudflare.com/client/v4/radar/attacks/layer7/top/attacks`
      );
      for (const [k, v] of [
        ["limit", limit],
        ["name", name],
        ["dateRange", dateRange],
        ["dateStart", dateStart],
        ["dateEnd", dateEnd],
        ["asn", asn],
        ["location", location],
        ["limitDirection", limitDirection],
        ["limitPerLocation", limitPerLocation],
        ["magnitude", magnitude],
        ["format", format],
      ]) {
        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