#ifndef CRIBRA_H
#define CRIBRA_H
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#define ABI_VERSION_MAJOR 0
#define ABI_VERSION_MINOR 1
#define ABI_VERSION_PATCH 0
typedef struct CribraBatchResults CribraBatchResults;
typedef struct CribraBuilder CribraBuilder;
typedef struct CribraError CribraError;
typedef struct CribraOutput CribraOutput;
typedef struct CribraReport CribraReport;
typedef struct CribraScanner CribraScanner;
typedef struct CribraShareBundle CribraShareBundle;
typedef uint32_t CribraStatus;
typedef uint32_t CribraCandidateKind;
typedef uint32_t CribraCandidateEvidence;
typedef struct CribraCandidateView {
CribraCandidateKind kind;
size_t start;
size_t end;
size_t line;
size_t column;
CribraCandidateEvidence evidence;
} CribraCandidateView;
typedef struct CribraStringView {
const uint8_t *ptr;
size_t len;
} CribraStringView;
typedef struct CribraBatchEntryView {
struct CribraStringView key;
size_t source_bytes;
size_t finding_count;
size_t candidate_count;
} CribraBatchEntryView;
typedef uint32_t CribraSeverity;
typedef uint32_t CribraConfidence;
typedef uint32_t CribraRemediation;
typedef struct CribraFindingView {
struct CribraStringView rule_id;
size_t start;
size_t end;
size_t line;
size_t column;
CribraSeverity severity;
CribraConfidence confidence;
CribraRemediation remediation;
} CribraFindingView;
typedef struct CribraBatchSummary {
size_t sources;
size_t source_bytes;
size_t findings;
size_t candidates;
} CribraBatchSummary;
typedef uint32_t CribraRuleKind;
typedef struct CribraRuleConfig {
CribraRuleKind kind;
struct CribraStringView id;
struct CribraStringView value;
CribraSeverity severity;
CribraRemediation remediation;
} CribraRuleConfig;
typedef uint32_t CribraExplanationKind;
typedef uint32_t CribraDetectionMode;
typedef struct CribraExplanationView {
CribraExplanationKind kind;
CribraDetectionMode detection_mode;
CribraCandidateEvidence candidate_evidence;
} CribraExplanationView;
typedef struct CribraBatchInput {
struct CribraStringView key;
struct CribraStringView source;
} CribraBatchInput;
typedef uint32_t CribraBatchExecution;
typedef uint32_t CribraShareMode;
typedef struct CribraShareBundleConfig {
CribraShareMode mode;
const uint8_t *key;
size_t key_len;
struct CribraStringView text;
size_t digest_bytes;
} CribraShareBundleConfig;
typedef struct CribraShareEntryView {
struct CribraStringView key;
struct CribraStringView content;
} CribraShareEntryView;
typedef struct CribraScanSummaryView {
size_t scanned_sources;
size_t scanned_bytes;
size_t reports_with_findings;
size_t reports_without_findings;
size_t total_findings;
size_t total_candidates;
size_t reports_with_candidates;
size_t critical;
size_t high;
size_t medium;
size_t low;
size_t info;
} CribraScanSummaryView;
typedef struct CribraShareManifestView {
CribraShareMode mode;
struct CribraScanSummaryView summary;
uint64_t generated_at_secs;
uint32_t generated_at_nanos;
} CribraShareManifestView;
typedef struct CribraPseudonymizeConfig {
const uint8_t *key;
size_t key_len;
struct CribraStringView prefix;
size_t digest_bytes;
} CribraPseudonymizeConfig;
typedef struct CribraSynthesizeConfig {
const uint8_t *key;
size_t key_len;
struct CribraStringView marker;
} CribraSynthesizeConfig;
typedef struct CribraTemplateConfig {
struct CribraStringView namespace_;
uint8_t numbered;
} CribraTemplateConfig;
#define CRIBRA_BATCH_EXECUTION_AUTO 0
#define CRIBRA_BATCH_EXECUTION_SERIAL 1
#define CRIBRA_BUILD_ERROR 4
#define CRIBRA_CANDIDATE_EVIDENCE_NONE 0
#define CRIBRA_CANDIDATE_EVIDENCE_STRUCTURAL 1
#define CRIBRA_CANDIDATE_EVIDENCE_UNKNOWN 4294967295
#define CRIBRA_CANDIDATE_KIND_NONE 0
#define CRIBRA_CANDIDATE_KIND_RECOVERY_LIKE_CODE 1
#define CRIBRA_CANDIDATE_KIND_UNKNOWN 4294967295
#define CRIBRA_CONFIDENCE_HIGH 2
#define CRIBRA_CONFIDENCE_LOW 0
#define CRIBRA_CONFIDENCE_MEDIUM 1
#define CRIBRA_DETECTION_MODE_CONTEXTUAL 3
#define CRIBRA_DETECTION_MODE_DETERMINISTIC 2
#define CRIBRA_DETECTION_MODE_MATCHER_ONLY 1
#define CRIBRA_DETECTION_MODE_NONE 0
#define CRIBRA_DETECTION_MODE_UNKNOWN 4294967295
#define CRIBRA_EXPLANATION_AMBIGUOUS 2
#define CRIBRA_EXPLANATION_CLASSIFIED 1
#define CRIBRA_EXPLANATION_NONE 0
#define CRIBRA_EXPLANATION_UNKNOWN 4294967295
#define CRIBRA_INTERNAL_ERROR 255
#define CRIBRA_INVALID_ARGUMENT 1
#define CRIBRA_INVALID_UTF8 2
#define CRIBRA_OK 0
#define CRIBRA_OUT_OF_RANGE 6
#define CRIBRA_REMEDIATION_NONE 0
#define CRIBRA_REMEDIATION_REMOVE_SENSITIVE_VALUE 5
#define CRIBRA_REMEDIATION_REPLACE_PRIVATE_KEY 4
#define CRIBRA_REMEDIATION_REVIEW_SENSITIVE_HASH 6
#define CRIBRA_REMEDIATION_REVOKE_AND_ROTATE_CREDENTIAL 1
#define CRIBRA_REMEDIATION_ROTATE_CREDENTIAL 2
#define CRIBRA_REMEDIATION_ROTATE_PASSWORD 3
#define CRIBRA_REMEDIATION_UNKNOWN 4294967295
#define CRIBRA_RULE_ERROR 3
#define CRIBRA_RULE_KIND_LITERAL 0
#define CRIBRA_RULE_KIND_PATTERN 3
#define CRIBRA_RULE_KIND_PREFIX 1
#define CRIBRA_RULE_KIND_SUFFIX 2
#define CRIBRA_SEVERITY_CRITICAL 4
#define CRIBRA_SEVERITY_HIGH 3
#define CRIBRA_SEVERITY_INFO 0
#define CRIBRA_SEVERITY_LOW 1
#define CRIBRA_SEVERITY_MEDIUM 2
#define CRIBRA_SHARE_MODE_PSEUDONYMIZE 2
#define CRIBRA_SHARE_MODE_REDACT 0
#define CRIBRA_SHARE_MODE_SYNTHESIZE 3
#define CRIBRA_SHARE_MODE_TEMPLATE 1
#define CRIBRA_SHARE_MODE_UNKNOWN 4294967295
#define CRIBRA_TRANSFORM_ERROR 5
#ifdef __cplusplus
extern "C" {
#endif
uint32_t cribra_abi_version_major(void);
uint32_t cribra_abi_version_minor(void);
uint32_t cribra_abi_version_patch(void);
CribraStatus cribra_batch_results_candidate_at(const struct CribraBatchResults *results,
size_t entry_index,
size_t candidate_index,
struct CribraCandidateView *out_candidate);
CribraStatus cribra_batch_results_count(const struct CribraBatchResults *results,
size_t *out_count);
CribraStatus cribra_batch_results_entry_at(const struct CribraBatchResults *results,
size_t index,
struct CribraBatchEntryView *out_entry);
CribraStatus cribra_batch_results_finding_at(const struct CribraBatchResults *results,
size_t entry_index,
size_t finding_index,
struct CribraFindingView *out_finding);
void cribra_batch_results_free(struct CribraBatchResults *results);
CribraStatus cribra_batch_results_summary(const struct CribraBatchResults *results,
struct CribraBatchSummary *out_summary);
CribraStatus cribra_builder_add_current_builtins(struct CribraBuilder *builder);
CribraStatus cribra_builder_add_rule(struct CribraBuilder *builder,
const struct CribraRuleConfig *config,
struct CribraError **out_error);
CribraStatus cribra_builder_build(struct CribraBuilder *builder,
struct CribraScanner **out_scanner,
struct CribraError **out_error);
void cribra_builder_free(struct CribraBuilder *builder);
CribraStatus cribra_builder_new(struct CribraBuilder **out_builder);
void cribra_error_free(struct CribraError *error);
CribraStatus cribra_error_message(const struct CribraError *error,
struct CribraStringView *out_message);
CribraStatus cribra_error_status(const struct CribraError *error, CribraStatus *out_status);
void cribra_output_free(struct CribraOutput *output);
CribraStatus cribra_output_view(const struct CribraOutput *output,
struct CribraStringView *out_view);
CribraStatus cribra_report_candidate_at(const struct CribraReport *report,
size_t index,
struct CribraCandidateView *out_candidate);
CribraStatus cribra_report_candidate_count(const struct CribraReport *report, size_t *out_count);
CribraStatus cribra_report_explain_candidate(const struct CribraReport *report,
size_t index,
struct CribraExplanationView *out_explanation);
CribraStatus cribra_report_finding_at(const struct CribraReport *report,
size_t index,
struct CribraFindingView *out_finding);
CribraStatus cribra_report_finding_count(const struct CribraReport *report, size_t *out_count);
void cribra_report_free(struct CribraReport *report);
CribraStatus cribra_scanner_explain_finding(const struct CribraScanner *scanner,
const struct CribraReport *report,
size_t index,
struct CribraExplanationView *out_explanation,
struct CribraError **out_error);
void cribra_scanner_free(struct CribraScanner *scanner);
CribraStatus cribra_scanner_new_current(struct CribraScanner **out_scanner);
CribraStatus cribra_scanner_scan(const struct CribraScanner *scanner,
const uint8_t *source,
size_t source_len,
struct CribraReport **out_report,
struct CribraError **out_error);
CribraStatus cribra_scanner_scan_batch(const struct CribraScanner *scanner,
const struct CribraBatchInput *inputs,
size_t input_count,
CribraBatchExecution execution,
struct CribraBatchResults **out_results,
struct CribraError **out_error);
CribraStatus cribra_share_bundle_build(const struct CribraBatchResults *results,
const struct CribraStringView *sources,
size_t source_count,
const struct CribraShareBundleConfig *config,
struct CribraShareBundle **out_bundle,
struct CribraError **out_error);
CribraStatus cribra_share_bundle_count(const struct CribraShareBundle *bundle, size_t *out_count);
CribraStatus cribra_share_bundle_entry_at(const struct CribraShareBundle *bundle,
size_t index,
struct CribraShareEntryView *out_entry);
void cribra_share_bundle_free(struct CribraShareBundle *bundle);
CribraStatus cribra_share_bundle_manifest(const struct CribraShareBundle *bundle,
struct CribraShareManifestView *out_manifest);
CribraStatus cribra_transform_pseudonymize(const uint8_t *source,
size_t source_len,
const struct CribraReport *report,
const struct CribraPseudonymizeConfig *config,
struct CribraOutput **out_output,
struct CribraError **out_error);
CribraStatus cribra_transform_redact(const uint8_t *source,
size_t source_len,
const struct CribraReport *report,
struct CribraOutput **out_output,
struct CribraError **out_error);
CribraStatus cribra_transform_redact_with(const uint8_t *source,
size_t source_len,
const struct CribraReport *report,
const uint8_t *replacement,
size_t replacement_len,
struct CribraOutput **out_output,
struct CribraError **out_error);
CribraStatus cribra_transform_synthesize(const uint8_t *source,
size_t source_len,
const struct CribraReport *report,
const struct CribraSynthesizeConfig *config,
struct CribraOutput **out_output,
struct CribraError **out_error);
CribraStatus cribra_transform_template(const uint8_t *source,
size_t source_len,
const struct CribraReport *report,
struct CribraOutput **out_output,
struct CribraError **out_error);
CribraStatus cribra_transform_template_with(const uint8_t *source,
size_t source_len,
const struct CribraReport *report,
const struct CribraTemplateConfig *config,
struct CribraOutput **out_output,
struct CribraError **out_error);
#ifdef __cplusplus
} #endif
#endif