Safeguard API for Asset discovery

Hi!

which is the method (api in the swagger) that I have to query to obtain the asset discovery and then be able to enter a list of IPs to be excluded in the "tab information"?

thanks

Michele

Parents
  • Hi Michele,

    Asset Discovery endpoints are located under AssetPartitions in the Swagger API.

    For example:

    POST​/v4​/AssetPartitions​/{id}​/DiscoveryJobs​/{jobId}​/RunDiscovery

    Thanks!

  • Hi Ahmad,

    thanks a lot for the reply. I still have some problem...

    GET /v4/AssetPartitions/{id}/DiscoveryJobs/{jobId} it's ok:

    {
      "Name": "windows",
      "AssetPartitionId": 2,
      "AssetPartitionName": "windows",
      "DiscoveryType": "Network",
      "DirectoryDiscoveryProperties": {
        "DirectoryId": null,
        "DirectoryName": null,
        "DirectoryNetworkAddress": null,
        "DirectoryPlatformId": null,
        "DirectoryPlatformType": "Unknown",
        "DirectoryPlatformDisplayName": null
      },
      "NetworkDiscoveryProperties": {
        "ScanOptions": {
          "OsFingerPrint": true,
          "ScanTimeout": 900
        },
        "ScanRules": [
          {
            "StartIp": "192.168.205.100",
            "EndIp": "192.168.205.200",
            "ExcludeIps": []
          }
        ]
      },
      "TaskProperties": {
        "HasTaskFailure": false,
        "LastAssetDiscoveryDate": "2022-05-10T15:00:22.294Z",
        "LastSuccessAssetDiscoveryDate": "2022-05-10T15:00:22.294Z",
        "LastFailureAssetDiscoveryDate": null,
        "FailedAssetDiscoveryAttempts": 0,
        "NextAssetDiscoveryDate": "2022-05-11T14:58:00Z",
        "LastAssetDiscoveryTaskId": "dd3a2b7a-d071-11ec-b324-11ddbc56d47a"
      },
      "Rules": [
        {
          "Name": "windows",
          "AssetTemplate": {
            "PasswordProfile": {
              "Id": 2,
              "Name": "windows Profile",
              "EffectiveId": 2,
              "EffectiveName": "windows Profile"
            },
            "SshKeyProfile": {
              "Id": null,
              "Name": null,
              "EffectiveId": null,
              "EffectiveName": null
            },
            "AccountDiscoveryScheduleId": null,
            "AccountDiscoveryScheduleName": null,
            "ManagedNetworkId": null,
            "ManagedNetworkName": null,
            "PlatformId": null,
            "PlatformType": null,
            "PlatformFamily": null,
            "PlatformDisplayName": null,
            "ConnectionProperties": {
              "ServiceAccountUniqueObjectId": null,
              "ServiceAccountSecurityId": null,
              "EnablePassword": null,
              "EnableHasPassword": false,
              "CommandTimeout": 20,
              "WorkstationId": null,
              "ClientId": null,
              "ServiceAccountProfileId": null,
              "ServiceAccountProfileName": null,
              "ServiceAccountSshKeyProfileId": null,
              "ServiceAccountSshKeyProfileName": null,
              "UseSslEncryption": true,
              "VerifySslCertificate": true,
              "Instance": null,
              "ServiceName": null,
              "SslThumbprint": null,
              "PrivilegeElevationCommand": null,
              "AccessKeyId": null,
              "SecretKey": null,
              "HasSecretKey": false,
              "OraclePrivileges": null,
              "UseNamedPipeForServiceAccountConnection": false,
              "RegisteredConnectorId": null,
              "TacacsSecret": null,
              "HasTacacsSecret": false,
              "UseTopSecretInterval": false,
              "ServiceAccountId": null,
              "ServiceAccountName": "iamadmin",
              "EffectiveServiceAccountName": "iamadmin",
              "ServiceAccountDomainName": null,
              "ServiceAccountDistinguishedName": null,
              "EffectiveServiceAccountDistinguishedName": null,
              "ServiceAccountCredentialType": "Password",
              "ServiceAccountPassword": null,
              "ServiceAccountHasPassword": true,
              "ServiceAccountSshKey": {
                "PrivateKey": null,
                "Passphrase": null,
                "PublicKey": null,
                "Comment": null,
                "Fingerprint": null,
                "FingerprintSha256": null,
                "KeyType": null,
                "KeyLength": null
              },
              "ServiceAccountHasSshKey": false,
              "Port": null,
              "ServiceAccountAssetId": null,
              "ServiceAccountAssetName": null,
              "ServiceAccountAssetPlatformId": 0,
              "ServiceAccountAssetPlatformType": "Unknown",
              "ServiceAccountAssetPlatformDisplayName": "Unknown",
              "ServiceAccountNetbiosName": null
            },
            "SessionAccessProperties": {
              "AllowSessionRequests": true,
              "SshSessionPort": null,
              "RemoteDesktopSessionPort": null,
              "TelnetSessionPort": null
            },
            "Tags": []
          },
          "Conditions": [
            {
              "ConditionType": "PropertyConstraint",
              "AdGroups": [],
              "LdapFilter": null,
              "PropertyConstraints": [
                {
                  "PropertyName": "OperatingSystemName",
                  "Operator": "Contains",
                  "Value": "windows"
                }
              ],
              "SearchBase": null,
              "SearchScope": "SubTree"
            }
          ]
        }
      ],
      "Id": 11,
      "Description": null,
      "CreatedDate": "2021-07-06T10:13:01Z",
      "CreatedByUserId": 1,
      "CreatedByUserDisplayName": "s2e admin",
      "ScheduleType": "Daily",
      "TimeZoneId": "W. Europe Standard Time",
      "TimeZoneDisplayName": "(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna",
      "RepeatInterval": 1,
      "RepeatMonthlyScheduleType": null,
      "RepeatWeekOfMonth": null,
      "RepeatDayOfWeek": null,
      "RepeatDayOfMonth": null,
      "RepeatDaysOfWeek": [],
      "TimeOfDayType": "Instant",
      "StartHour": 16,
      "StartMinute": 58,
      "TimeOfDayIntervals": []
    }

    I've tried to insert IP in the exclusion list in:

    PUT /v4/AssetPartitions/{id}/DiscoveryJobs/{jobId}

    with this request:

    {
    "Name": "string",
    "AssetPartitionId": 0,
    "AssetPartitionName": "string",
    "DiscoveryType": "Directory",
    "DirectoryDiscoveryProperties": {
    "DirectoryId": 0,
    "DirectoryName": "string",
    "DirectoryNetworkAddress": "string",
    "DirectoryPlatformId": 0,
    "DirectoryPlatformType": "Unknown",
    "DirectoryPlatformDisplayName": "string"
    },
    "NetworkDiscoveryProperties": {
    "ScanOptions": {
    "OsFingerPrint": false,
    "ScanTimeout": 0
    },
    "ScanRules": [
    {
    "StartIp": "string",
    "EndIp": "string",
    "ExcludeIps": [ "192.168.1.11" ]
    }
    ]
    },
    "TaskProperties": {
    "HasTaskFailure": true,
    "LastAssetDiscoveryDate": "2022-05-09T15:56:29.284Z",
    "LastSuccessAssetDiscoveryDate": "2022-05-09T15:56:29.284Z",
    "LastFailureAssetDiscoveryDate": "2022-05-09T15:56:29.284Z",
    "FailedAssetDiscoveryAttempts": 0,
    "NextAssetDiscoveryDate": "2022-05-09T15:56:29.284Z",
    "LastAssetDiscoveryTaskId": "string"
    },
    "Rules": [
    {
    "Name": "string",
    "AssetTemplate": {
    "PasswordProfile": {
    "Id": 0,
    "Name": "string",
    "EffectiveId": 0,
    "EffectiveName": "string"
    },
    "SshKeyProfile": {
    "Id": 0,
    "Name": "string",
    "EffectiveId": 0,
    "EffectiveName": "string"
    },
    "AccountDiscoveryScheduleId": 0,
    "AccountDiscoveryScheduleName": "string",
    "ManagedNetworkId": 0,
    "ManagedNetworkName": "string",
    "PlatformId": 0,
    "PlatformType": "Unknown",
    "PlatformFamily": "None",
    "PlatformDisplayName": "string",
    "ConnectionProperties": {
    "ServiceAccountUniqueObjectId": "string",
    "ServiceAccountSecurityId": "string",
    "EnablePassword": "string",
    "EnableHasPassword": true,
    "CommandTimeout": 0,
    "WorkstationId": "string",
    "ClientId": 0,
    "ServiceAccountProfileId": 0,
    "ServiceAccountProfileName": "string",
    "ServiceAccountSshKeyProfileId": 0,
    "ServiceAccountSshKeyProfileName": "string",
    "UseSslEncryption": true,
    "VerifySslCertificate": true,
    "Instance": "string",
    "ServiceName": "string",
    "SslThumbprint": "string",
    "PrivilegeElevationCommand": "string",
    "AccessKeyId": "string",
    "SecretKey": "string",
    "HasSecretKey": true,
    "OraclePrivileges": "string",
    "UseNamedPipeForServiceAccountConnection": true,
    "RegisteredConnectorId": 0,
    "TacacsSecret": "string",
    "HasTacacsSecret": true,
    "UseTopSecretInterval": true,
    "ServiceAccountId": 0,
    "ServiceAccountName": "string",
    "EffectiveServiceAccountName": "string",
    "ServiceAccountDomainName": "string",
    "ServiceAccountDistinguishedName": "string",
    "EffectiveServiceAccountDistinguishedName": "string",
    "ServiceAccountCredentialType": "None",
    "ServiceAccountPassword": "string",
    "ServiceAccountHasPassword": true,
    "ServiceAccountSshKey": {
    "PrivateKey": "string",
    "Passphrase": "string",
    "PublicKey": "string",
    "Comment": "string",
    "Fingerprint": "string",
    "FingerprintSha256": "string",
    "KeyType": "Unknown",
    "KeyLength": 0
    },
    "ServiceAccountHasSshKey": true,
    "Port": 0,
    "ServiceAccountAssetId": 0,
    "ServiceAccountAssetName": "string",
    "ServiceAccountAssetPlatformId": 0,
    "ServiceAccountAssetPlatformType": "Unknown",
    "ServiceAccountAssetPlatformDisplayName": "string",
    "ServiceAccountNetbiosName": "string"
    },
    "SessionAccessProperties": {
    "AllowSessionRequests": true,
    "SshSessionPort": 0,
    "RemoteDesktopSessionPort": 0,
    "TelnetSessionPort": 0
    },
    "Tags": [
    {
    "Id": 0,
    "Name": "string",
    "Description": "string",
    "AdminAssigned": true
    }
    ]
    },
    "Conditions": [
    {
    "ConditionType": "FindAll",
    "AdGroups": [
    "string"
    ],
    "LdapFilter": "string",
    "PropertyConstraints": [
    {
    "PropertyName": "Name",
    "Operator": "Equals",
    "Value": "string"
    }
    ],
    "SearchBase": "string",
    "SearchScope": "OneLevel"
    }
    ]
    }
    ],
    "Id": 0,
    "Description": "string",
    "CreatedDate": "2022-05-09T15:56:29.284Z",
    "CreatedByUserId": 0,
    "CreatedByUserDisplayName": "string",
    "ScheduleType": "Never",
    "TimeZoneId": "string",
    "TimeZoneDisplayName": "string",
    "RepeatInterval": 0,
    "RepeatMonthlyScheduleType": "DayOfMonth",
    "RepeatWeekOfMonth": "First",
    "RepeatDayOfWeek": "Sunday",
    "RepeatDayOfMonth": 0,
    "RepeatDaysOfWeek": [
    "Sunday"
    ],
    "TimeOfDayType": "Instant",
    "StartHour": 0,
    "StartMinute": 0,
    "TimeOfDayIntervals": [
    {
    "StartHour": 0,
    "StartMinute": 0,
    "EndHour": 0,
    "EndMinute": 0,
    "Iterations": 0
    }
    ]
    }

    but it returns an error:

    {
      "Code": 70000,
      "Message": "The request is invalid.",
      "ModelState": {
        "entity.RepeatInterval": [
          "The field RepeatInterval must be between 1 and 2147483647."
        ],
        "entity.RepeatDayOfMonth": [
          "The field RepeatDayOfMonth must be between 1 and 31."
        ],
        "entity.DirectoryDiscoveryProperties.DirectoryId": [
          "The field DirectoryId must be a valid non-zero database ID."
        ],
        "entity.TimeOfDayIntervals[0].Iterations": [
          "The field Iterations must be between 1 and 1440."
        ],
        "entity.Rules[0].AssetTemplate.PlatformId": [
          "The field PlatformId must be a valid non-zero database ID."
        ],
        "entity.Rules[0].AssetTemplate.ManagedNetworkId": [
          "The field ManagedNetworkId must be a valid non-zero database ID."
        ],
        "entity.Rules[0].AssetTemplate.ConnectionProperties.Port": [
          "The field Port must be between 1 and 65535."
        ],
        "entity.Rules[0].AssetTemplate.ConnectionProperties.CommandTimeout": [
          "The field CommandTimeout must be between 1 and 32767."
        ],
        "entity.Rules[0].AssetTemplate.ConnectionProperties.ServiceAccountProfileId": [
          "The field ServiceAccountProfileId must be a valid non-zero database ID."
        ],
        "entity.Rules[0].AssetTemplate.ConnectionProperties.ServiceAccountSshKeyProfileId": [
          "The field ServiceAccountSshKeyProfileId must be a valid non-zero database ID."
        ],
        "entity.Rules[0].AssetTemplate.SessionAccessProperties.SshSessionPort": [
          "The field SshSessionPort must be between 1 and 65535."
        ],
        "entity.Rules[0].AssetTemplate.SessionAccessProperties.TelnetSessionPort": [
          "The field TelnetSessionPort must be between 1 and 65535."
        ],
        "entity.Rules[0].AssetTemplate.SessionAccessProperties.RemoteDesktopSessionPort": [
          "The field RemoteDesktopSessionPort must be between 1 and 65535."
        ]
      }
    }

    Do you have any suggestion?

    Thanks a lot

    Michele

  • Hi Michele,

    The request that has the ExcludeIPs was using DiscoveryType as Directory instead of Network.

    It may be easier to copy the response body from the GET call and then use that to populate the request body for the PUT call then modify the "ExcludeIps": [ "192.168.1.11" ]

    Thanks!

Reply Children
No Data