0

Get topology path

by
Published today

Path analysis between a source and a destination: the devices crossed and whether the traffic is allowed.

Script tufin_securetrack Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 6 hours ago
1
//native
2

3
/**
4
 * Get topology path
5
 * Run a path analysis between a source and a destination: SecureTrack returns the devices the traffic crosses and whether it is allowed.
6
 */
7
export async function main(
8
  auth: RT.TufinSecuretrack,
9
  src: string,
10
  dst: string,
11
  service: string | undefined
12
) {
13
  const base = auth.base_url.replace(/\/+$/, "")
14
  const url = new URL(`${base}/securetrack/api/topology/path`)
15
  url.searchParams.append("src", src)
16
  url.searchParams.append("dst", dst)
17
  url.searchParams.append("service", service || "Any")
18

19
  const response = await fetch(url, {
20
    method: "GET",
21
    headers: {
22
      Authorization: `Basic ${btoa(`${auth.username}:${auth.password}`)}`,
23
      Accept: "application/json",
24
    },
25
  })
26

27
  if (!response.ok) {
28
    throw new Error(`${response.status} ${await response.text()}`)
29
  }
30

31
  return await response.json()
32
}
33