Integration
A C API with a header-only C++ wrapper, shared or static, with samples in C, C++ and Python. Scan files or buffers from any number of threads on one handle, while models update with no restart.
The call order
Initialize once, update the models, then scan files or buffers on that one handle. Pass NULL for the options to take the defaults, and release each result when you are done.
semantics_av_init_options_t opt = semantics_av_init_options_default();
opt.base_path = "./semantics_av_data";
opt.api_key = api_key;
semantics_av_handle_t *h;
semantics_av_init(&opt, &h);
semantics_av_update_models(h, NULL); /* all models */
semantics_av_scan_result_t r = {0};
semantics_av_scan_file(h, path, &r, NULL);
/* r.verdict: CLEAN, MALICIOUS or UNKNOWN */
/* r.entries: one record per file */
semantics_av_free_scan_result(&r);
semantics_av_cleanup(h); The result
- MALICIOUS At least one file is malicious. The result names it.
- CLEAN Every file was examined and none is malicious.
- UNKNOWN The scan reached neither a CLEAN nor a MALICIOUS verdict. The entry flags give the reason.
Scans write temporary files only to the directory set in temp_dir.
Return codes
A scan returns SEMANTICS_AV_OK whenever the input was examined. Read the verdict for the result. Any other code means the call did not complete. The codes are declared in the shipped header.
Success
-
SEMANTICS_AV_OK0 The input was examined. Read the verdict for the result.
Parameters and state
-
SEMANTICS_AV_INVALID_PARAM-100 A required argument was missing or out of range. -
SEMANTICS_AV_ALREADY_INITIALIZED-102 The handle was already initialized. -
SEMANTICS_AV_NOT_INITIALIZED-103 The call needs an initialized handle.
Input and memory
-
SEMANTICS_AV_FILE_NOT_FOUND-200 The path did not resolve to a readable file. -
SEMANTICS_AV_FILE_READ_ERROR-202 The file could not be read. -
SEMANTICS_AV_MEMORY_ERROR-203 Memory could not be allocated.
Format
-
SEMANTICS_AV_UNSUPPORTED_FORMAT-300 The input is not a format this call accepts. -
SEMANTICS_AV_CORRUPTED_DATA-301 The input was damaged beyond reading. -
SEMANTICS_AV_INVALID_FORMAT-302 The input did not match its declared format.
Models
-
SEMANTICS_AV_MODEL_NOT_FOUND-400 No model is installed for this input. -
SEMANTICS_AV_MODEL_LOAD_ERROR-401 An installed model could not be loaded. -
SEMANTICS_AV_MODEL_CORRUPTED-402 An installed model failed its integrity check. -
SEMANTICS_AV_INFERENCE_ERROR-403 The model could not score the input.
License and verification
-
SEMANTICS_AV_VERIFICATION_FAILED-500 A signature did not verify. -
SEMANTICS_AV_AUTHENTICATION_FAILED-501 The license key was missing or rejected. -
SEMANTICS_AV_ACCESS_DENIED-502 The key is not permitted this call.
Network and service
-
SEMANTICS_AV_NETWORK_ERROR-600 An update or analysis request could not reach the service. -
SEMANTICS_AV_NETWORK_TIMEOUT-601 The request did not complete in time. -
SEMANTICS_AV_RATE_LIMITED-602 The service asked the client to slow down. -
SEMANTICS_AV_SERVER_ERROR-603 The service reported an error. -
SEMANTICS_AV_SERVICE_UNAVAILABLE-604 The service was unavailable.
Internal
-
SEMANTICS_AV_INTERNAL_ERROR-901 An unexpected internal condition, including a NULL base path.
The option tables and the full result structure are in the technical document, provided with an evaluation.
API overview
-
semantics_av_init / _cleanupOpen and close a handle. -
semantics_av_update_modelsDownload and install model updates. -
semantics_av_scan_file / _bufferScan a file or a buffer. -
semantics_av_free_scan_resultRelease a result. -
semantics_av_get_model_metadataRead an installed model's version and size. -
semantics_av_analyze_file / _bufferRequest an analysis report for one file. -
semantics_av_submit_file / _bufferSubmit a file to your on-premises server without waiting for the report.
Analysis
Call analyze on a flagged file to get its family and its closest known samples. It accepts a single executable, script or document, and returns UNSUPPORTED_FORMAT for a container. What it sends is listed in the data statement.
The call
analyze waits for the report. submit, for an on-premises server, returns as soon as the server accepts the request.
semantics_av_analysis_result_t a = {0};
semantics_av_analyze_file(h, path, &a, NULL);
/* a.detection.verdict and a.detection.signature; a.intelligence.similar_samples */
semantics_av_free_analysis_result(&a); What the report contains
detectionThe verdict, its confidence, and a malware family name.intelligence.similar_samplesThe closest known malware samples, each with its own family.intelligence.statisticsCounts and similarity across those samples, by verdict and by family.
Samples
Each sample starts with its build and run command. With an on-premises server, pass the server address as an extra argument.
gcc -o example example.c -I../../include -L../../lib -lsemantics_av -Wl,-rpath,../../lib
./example "API key" /path/to/file g++ -std=c++17 -o example example.cpp -I../../include -L../../lib -lsemantics_av -Wl,-rpath,../../lib
./example "API key" /path/to/file python3 example.py "API key" /path/to/file Evaluate SemanticsAV on your own files
Evaluating SemanticsAV is free of charge. You get the SDK, the technical document, sample code and technical support.
SemanticsAV is licensed by OEM or commercial contract.