Getting Kaspersky Industrial CyberSecurity for Networks configuration

This section explains how to obtain Kaspersky Industrial CyberSecurity for Networks configuration by using Kaspersky Industrial CyberSecurity for Networks API RPC calls.

Overview

You can get Kaspersky Industrial CyberSecurity for Networks configuration by using the ConfigurationProvider service methods. This service is defined in the configuration_provider_service.proto file. Messages and enumerations are defined in the configuration_provider.proto and configuration_provider_service.proto files.

The ConfigurationProvider service has the following methods for getting Kaspersky Industrial CyberSecurity for Networks configuration:

Getting configuration metadata (example)

To get configuration metadata, use the GetConfigurationMetadata method.

In the following example, a stub requests configuration metadata.

configStub = configuration_provider_service_pb2_grpc.ConfigurationProviderStub(channel)

 

#rpc GetConfigurationMetadata(google.protobuf.Empty) returns(ConfigurationMetadata);

 

response = configStub.GetConfigurationMetadata(google_dot_protobuf_dot_empty__pb2.Empty())

 

print("Configuration version:", response.configurationVersion,

"| Project name:", response.projectName,

"| Product version:", response.productVersion,

"| Timestamp:", datetime.datetime.utcfromtimestamp(response.timestamp.seconds).strftime('%Y-%m-%d %H:%M:%S')

)

Getting a list of PLCs (example)

To get a list of PLCs, use the GetPlcConfiguration method. In the following example, a stub requests a list of PLCs and prints the received information.

configStub = configuration_provider_service_pb2_grpc.ConfigurationProviderStub(channel)

 

#rpc GetPlcConfiguration(google.protobuf.Empty) returns(stream PlcConfiguration);

 

response = configStub.GetPlcConfiguration(google_dot_protobuf_dot_empty__pb2.Empty())

 

for plc in response:

print("\n\n")

print("PLC:",

"| Hash id:", plc.hashId,

"| Name:", plc.plcName,

"| Type:", plc.plcType

)

for protocol in plc.plcProtos:

print("Protocol id:", protocol)

Getting protocol configuration for a PLC (example)

To get configuration for all protocols of a certain PLC, use the GetProtocolConfiguration method.

In the following example, a stub requests protocol configuration and specifies hash identifier of a PLC (in this example, the value of this identifier is 1).

configStub = configuration_provider_service_pb2_grpc.ConfigurationProviderStub(channel)

 

#rpc GetProtocolConfiguration(HashIdValue) returns(stream ProtocolConfiguration);

 

request = configuration_provider_service_pb2.HashIdValue(hashId=1)

 

response = configStub.GetProtocolConfiguration(request)

 

for protocol in response:

print("\n\n")

print("Protocol",

"| Hash id:", protocol.hashId,

"| Name:", protocol.protocolName,

"| Type:", protocol.protocolType)

 

if protocol.HasField("deviceAddress"):

print("Device address:",

"| Rack:", protocol.deviceAddress.rack,

"| Slot:", protocol.deviceAddress.slot)

 

for taddr in protocol.transportAddresses:

print("Transport address:",

"| MAC:", taddr.mac,

"| IP:", taddr.ip,

"| Port:", taddr.port,

"| Domain:", taddr.domainId)

Getting tags for a PLC (example)

To get tag descriptors for the specified PLC, use the GetTagsForPlc method. In the following example, a stub requests tags for a specified hash identifier of a PLC (in this example, the value of this identifier is 1).

configStub = configuration_provider_service_pb2_grpc.ConfigurationProviderStub(channel)

 

#rpc GetTagsForPlc(HashIdValue) returns(stream TagDescriptor);

 

request = configuration_provider_service_pb2.HashIdValue(hashId=1)

 

response = configStub.GetTagsForPlc(request)

 

for tag_descriptor in response:

print("Descriptor:",

"| Id:", tag_descriptor.tagId,

"| Name:", tag_descriptor.tagName,

"| Value type:", tag_descriptor.tagType,

"| Units:", tag_descriptor.measurementUnits,

"| Description:", tag_descriptor.tagDescription)

Getting tags for protocol (example)

To get tag descriptors for the specified protocol, use the GetTagsForProtocol method. In the following example, a stub requests tags for a specified hash identifier of the protocol (in this example, the value of this identifier is 1).

configStub = configuration_provider_service_pb2_grpc.ConfigurationProviderStub(channel)

 

#rpc GetTagsForProtocol(HashIdValue) returns(stream TagDescriptor);

 

request = configuration_provider_service_pb2.HashIdValue(hashId=1)

 

response = configStub.GetTagsForProtocol(request)

 

for tag_descriptor in response:

print("Descriptor:",

"| Id:", tag_descriptor.tagId,

"| Name:", tag_descriptor.tagName,

"| Value type:", tag_descriptor.tagType,

"| Units:", tag_descriptor.measurementUnits,

"| Description:", tag_descriptor.tagDescription)

Getting event descriptors (example)

To get event descriptors, use the GetEventDescriptors method. In the following example, a stub requests event descriptors and prints the response.

configStub = configuration_provider_service_pb2_grpc.ConfigurationProviderStub(channel)

 

#rpc GetEventDescriptors(google.protobuf.Empty) returns(stream EventDescriptor);

response = configStub.GetEventDescriptors(google_dot_protobuf_dot_empty__pb2.Empty())

 

for event_descriptor in response:

print("Event descriptor:",

"| Type id:", event_descriptor.eventTypeId,

"| Title:", event_descriptor.eventTitle,

"| Severity:", event_descriptor.severity,

"| Technology:", event_descriptor.technology,

"| Description:", event_descriptor.eventDescription)

Page top