1. Getting Started

The following documents the C interface to the Vulnerability Module Source including data types, functions and a diagram of internal classes.

Binaries

The following is the binary which is required for Vulnerability Module Source to run properly.

libwaofflinevmodapi.lib

The entry point into the Vulnerability Module Source and the only one that needs to be linked by integrating applications

Headers

The following are the C header files made available by the Vulnerability Module Source

wa_offline_vmod_wchar_functions.h

The only header file that should be explicitly included in integrating applications to use ov_char interface. Containing signature functions exported by libwaofflinevmodapi.lib, and including the other header files, making relevant defines and typedefs available.

wa_offline_vmod_json_functions.h

The only header file that should be explicitly included in integrating applications to use JSON interface. Contains signature functions in the JSON input format exported by libwaofflinevmodapi.lib, and includes the other header files, making relevant defines and typedefs available.

wa_offline_vmod_invoke_query.h

Defines query methods.

wa_offline_vmod_error_codes.h

Defines possible error codes.

wa_offline_vmod_json_keys.h

Defines json object keys that map to json values.

wa_offline_vmod_utils_json.h

Defines JSON class used by functions in wa_offline_vmod_json_functions.h.

wa_offline_vmod_defs.h

Defines specific type for ov_char and ov_string and other platform-specific macros.

Datatypes

Vulnerability Module Source defines the following datatypes:

ov_char

Defined to be wchar_t if macro OFFLINE_VMOD_CHAR is not defined and defined to be char if macro OFFLINE_VMOD_CHAR is defined.

ov_string

Defined to be wstring if macro OFFLINE_VMOD_CHAR is not defined and defined to be string if macro OFFLINE_VMOD_CHAR is defined.

When Vulnerability Module Source is built with the appropriate macros, the corresponding datatypes take effect throughout the library. The same macros that define datatypes of the built library should be defined before including library's header files to make sure client code use the same datatypes as being used by the library.

Functions

All functions will return a boolean value that is used to determine the success or failure of the function call

wa_offline_vmod_setup : Initialize the Vulnerability Module Source interface.

void __stdcall wa_offline_vmod_setup();


(Deprecated) wa_offline_vmod_load_database_from_path : Will load the database for subsequent Vulnerability Module Source calls.

bool __stdcall wa_offline_vmod_load_database_from_path(
const ov_char * path
);

Parameter:

path

[IN]

The path of the database file.

Remarks: This function is deprecated. User should use wa_offline_vmod_read_database_from_path instead.


(Deprecated) wa_offline_vmod_load_database_from_string : Will load the database for subsequent Vulnerability Module Source calls.

bool __stdcall wa_offline_vmod_load_database_from_string(
const ov_char * content
);

Parameter:

content

[IN]

The string content of the database.

Remarks: This function is deprecated. User should use wa_offline_vmod_read_database_from_string instead.

wa_offline_vmod_read_database_from_path : Will load the database for subsequent Vulnerability Module Source calls.

bool __stdcall wa_offline_vmod_load_database_from_path(
const ov_char * path,
ov_char **json_out
);

Parameter:

path

[IN]

The path of the database file.

json_out

[OUT]

The database reading result. User can never pass NULL, must pass a valid pointer that can be allocated with content. See how to handle output results for details.

Remarks: This function or wa_offline_vmod_read_database_from_string must be called after calling wa_offline_vmod_setup for Vulnerability Module Source to work properly. The json_out pointer will be allocated by this function. It is the caller's responsibility to call wa_offline_vmod_free on this pointer to release the memory back to the process.

wa_offline_vmod_read_database_from_string : Will load the database for subsequent Vulnerability Module Source calls.

bool __stdcall wa_offline_vmod_read_database_from_string(
const ov_char * content,
ov_char **json_out
);

Parameter:

content

[IN]

The string content of the database.

json_out

[OUT]

The database reading result. User can never pass NULL, must pass a valid pointer that can be allocated with content. See how to handle output results for details.

Remarks: This function or wa_offline_vmod_read_database_from_path must be called after calling wa_offline_vmod_setup for Vulnerability Module Source to work properly. The json_out pointer will be allocated by this function. It is the caller's responsibility to call wa_offline_vmod_free on this pointer to release the memory back to the process.

wa_offline_vmod_invoke : Performs an invocation call to the sdk.

bool __stdcall wa_offline_vmod_invoke(
const ov_char *json_in,
ov_char **json_out
);
bool __stdcall wa_offline_vmod_invoke(
const OfflineVMod::WaOVJson &json_in,
OfflineVMod::WaOVJson &json_out
);

If the sdk and required functionality are deployed and licensed, the call will then dispatch the JSON input for processing. If successful, the function returns true and the output result of the invocation will be returned in the json_out parameter. If fails, a false value will be returned and the error detail will be returned in the json_out parameter.

Parameter:

json_in

[IN]

The invocation input to dispatch to the component. The definition of the expected format is defined by the method_id parameter of the json_in

json_out

[OUT]

The invocation output result. If using ov_char interface, the user can never pass NULL, must pass a valid pointer that can be allocated with content. See how to handle output results for details.

Remarks: If using ov_char interface, the json_out pointer will be allocated by this function. It is the caller's responsibility to call wa_offline_vmod_free on this pointer to release the memory back to the process.

wa_offline_vmod_free : Will release the memory of the pointer allocated by Vulnerability Module Source calls.

void __stdcall wa_offline_vmod_free(
ov_char * json_data
);

wa_offline_vmod_invoke will allocate memory to the json_out parameters that contain the results of the function calls. It is up to the caller to release the memory allocated during these function calls using this function.

Parameter:

json_data

[IN,OUT]

The pointer to the memory that is to be released

wa_offline_vmod_teardown : Deinitializes the Vulnerability Module Source interface and destructs all internal structures created.

void __stdcall wa_offline_vmod_teardown();

This function must be called to release all internally held memory, handles, etc. Should only be called when your integration is finished using the SDK.

Class Diagram

The following is the class diagram of the Model component of Vulnerability Module Source:

images/download/attachments/24124504/OfflineVMod_class_diagram.png