Edits history of script submission #4779 for ' Create a device posture rule (cloudflare)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Cloudflare = {
      token: string;
      email: string;
      key: string;
    };
    /**
     * Create a device posture rule
     * Creates a new device posture rule.
     */
    export async function main(
      auth: Cloudflare,
      identifier: string,
      body: {
        description?: string;
        expiration?: string;
        input?:
          | {
              exists?: boolean;
              operating_system: "windows" | "linux" | "mac";
              path: string;
              sha256?: string;
              thumbprint?: string;
              [k: string]: unknown;
            }
          | {
              id: string;
              operating_system: "android" | "ios" | "chromeos";
              [k: string]: unknown;
            }
          | { domain?: string; operating_system: "windows"; [k: string]: unknown }
          | {
              operating_system: "windows";
              operator: "<" | "<=" | ">" | ">=" | "==";
              os_distro_name?: string;
              os_distro_revision?: string;
              os_version_extra?: string;
              version: string;
              [k: string]: unknown;
            }
          | {
              enabled: boolean;
              operating_system: "windows" | "mac";
              [k: string]: unknown;
            }
          | {
              operating_system: "windows" | "linux" | "mac";
              path: string;
              sha256?: string;
              thumbprint?: string;
              [k: string]: unknown;
            }
          | {
              operating_system: "windows" | "linux" | "mac";
              path: string;
              sha256?: string;
              thumbprint?: string;
              [k: string]: unknown;
            }
          | { checkDisks?: string[]; requireAll?: boolean; [k: string]: unknown }
          | {
              operating_system: "windows" | "linux" | "mac";
              path: string;
              sha256?: string;
              thumbprint?: string;
              [k: string]: unknown;
            }
          | { certificate_id: string; cn: string; [k: string]: unknown }
          | {
              compliance_status: "compliant" | "noncompliant" | "unknown";
              connection_id: string;
              [k: string]: unknown;
            }
          | {
              connection_id: string;
              operator?: "<" | "<=" | ">" | ">=" | "==";
              os?: string;
              overall?: string;
              sensor_config?: string;
              version?: string;
              versionOperator?: "<" | "<=" | ">" | ">=" | "==";
              [k: string]: unknown;
            }
          | {
              compliance_status:
                | "compliant"
                | "noncompliant"
                | "unknown"
                | "notapplicable"
                | "ingraceperiod"
                | "error";
              connection_id: string;
              [k: string]: unknown;
            }
          | {
              connection_id: string;
              countOperator: "<" | "<=" | ">" | ">=" | "==";
              issue_count: string;
              [k: string]: unknown;
            }
          | {
              connection_id: string;
              eid_last_seen?: string;
              operator?: "<" | "<=" | ">" | ">=" | "==";
              risk_level?: "low" | "medium" | "high" | "critical";
              scoreOperator?: "<" | "<=" | ">" | ">=" | "==";
              total_score?: number;
              [k: string]: unknown;
            }
          | {
              active_threats?: number;
              connection_id: string;
              infected?: boolean;
              is_active?: boolean;
              network_status?:
                | "connected"
                | "disconnected"
                | "disconnecting"
                | "connecting";
              operator?: "<" | "<=" | ">" | ">=" | "==";
              [k: string]: unknown;
            };
        match?: {
          platform?: "windows" | "mac" | "linux" | "android" | "ios";
          [k: string]: unknown;
        }[];
        name: string;
        schedule?: string;
        type:
          | "file"
          | "application"
          | "tanium"
          | "gateway"
          | "warp"
          | "disk_encryption"
          | "sentinelone"
          | "carbonblack"
          | "firewall"
          | "os_version"
          | "domain_joined"
          | "client_certificate"
          | "unique_client_id"
          | "kolide"
          | "tanium_s2s"
          | "crowdstrike_s2s"
          | "intune"
          | "workspace_one"
          | "sentinelone_s2s";
        [k: string]: unknown;
      }
    ) {
      const url = new URL(
        `https://api.cloudflare.com/client/v4/accounts/${identifier}/devices/posture`
      );
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "X-AUTH-EMAIL": auth.email,
          "X-AUTH-KEY": auth.key,
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.token,
        },
        body: JSON.stringify(body),
      });
      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;
    };
    /**
     * Create a device posture rule
     * Creates a new device posture rule.
     */
    export async function main(
      auth: Cloudflare,
      identifier: string,
      body: {
        description?: string;
        expiration?: string;
        input?:
          | {
              exists?: boolean;
              operating_system: "windows" | "linux" | "mac";
              path: string;
              sha256?: string;
              thumbprint?: string;
              [k: string]: unknown;
            }
          | {
              id: string;
              operating_system: "android" | "ios" | "chromeos";
              [k: string]: unknown;
            }
          | { domain?: string; operating_system: "windows"; [k: string]: unknown }
          | {
              operating_system: "windows";
              operator: "<" | "<=" | ">" | ">=" | "==";
              os_distro_name?: string;
              os_distro_revision?: string;
              os_version_extra?: string;
              version: string;
              [k: string]: unknown;
            }
          | {
              enabled: boolean;
              operating_system: "windows" | "mac";
              [k: string]: unknown;
            }
          | {
              operating_system: "windows" | "linux" | "mac";
              path: string;
              sha256?: string;
              thumbprint?: string;
              [k: string]: unknown;
            }
          | {
              operating_system: "windows" | "linux" | "mac";
              path: string;
              sha256?: string;
              thumbprint?: string;
              [k: string]: unknown;
            }
          | { checkDisks?: string[]; requireAll?: boolean; [k: string]: unknown }
          | {
              operating_system: "windows" | "linux" | "mac";
              path: string;
              sha256?: string;
              thumbprint?: string;
              [k: string]: unknown;
            }
          | { certificate_id: string; cn: string; [k: string]: unknown }
          | {
              compliance_status: "compliant" | "noncompliant" | "unknown";
              connection_id: string;
              [k: string]: unknown;
            }
          | {
              connection_id: string;
              operator?: "<" | "<=" | ">" | ">=" | "==";
              os?: string;
              overall?: string;
              sensor_config?: string;
              version?: string;
              versionOperator?: "<" | "<=" | ">" | ">=" | "==";
              [k: string]: unknown;
            }
          | {
              compliance_status:
                | "compliant"
                | "noncompliant"
                | "unknown"
                | "notapplicable"
                | "ingraceperiod"
                | "error";
              connection_id: string;
              [k: string]: unknown;
            }
          | {
              connection_id: string;
              countOperator: "<" | "<=" | ">" | ">=" | "==";
              issue_count: string;
              [k: string]: unknown;
            }
          | {
              connection_id: string;
              eid_last_seen?: string;
              operator?: "<" | "<=" | ">" | ">=" | "==";
              risk_level?: "low" | "medium" | "high" | "critical";
              scoreOperator?: "<" | "<=" | ">" | ">=" | "==";
              total_score?: number;
              [k: string]: unknown;
            }
          | {
              active_threats?: number;
              connection_id: string;
              infected?: boolean;
              is_active?: boolean;
              network_status?:
                | "connected"
                | "disconnected"
                | "disconnecting"
                | "connecting";
              operator?: "<" | "<=" | ">" | ">=" | "==";
              [k: string]: unknown;
            };
        match?: {
          platform?: "windows" | "mac" | "linux" | "android" | "ios";
          [k: string]: unknown;
        }[];
        name: string;
        schedule?: string;
        type:
          | "file"
          | "application"
          | "tanium"
          | "gateway"
          | "warp"
          | "disk_encryption"
          | "sentinelone"
          | "carbonblack"
          | "firewall"
          | "os_version"
          | "domain_joined"
          | "client_certificate"
          | "unique_client_id"
          | "kolide"
          | "tanium_s2s"
          | "crowdstrike_s2s"
          | "intune"
          | "workspace_one"
          | "sentinelone_s2s";
        [k: string]: unknown;
      }
    ) {
      const url = new URL(
        `https://api.cloudflare.com/client/v4/accounts/${identifier}/devices/posture`
      );
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "X-AUTH-EMAIL": auth.email,
          "X-AUTH-KEY": auth.key,
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.token,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 920 days ago