libxml-rs 0.1.0-alpha.21

Native-Rust forensic reimplementation of libxml2+libxslt with C ABI drop-in replacement. Cross-version oracle matrix (libxml2 2.7.8-2.15.3, libxslt 1.1.26-1.1.45) with semantic epochs correlated to upstream commits; full xmllint/xmlcatalog/xsltproc CLIs; differential-court-verified C API closure (xmlXPath*, xmlTextReader*, xmlTextWriter*, catalogs, serialization, data globals, chvalid, encoding, the full libxslt surface) — parity ledger at 0 missing for both libxml2 and libxslt. 1135 tests passing.
Documentation
/**
 * @file
 *
 * XSLT security API for libxml-rs.
 *
 * Upstream counterpart: libxslt/security.h (1.1.42 contract, R-000125).
 * The security model is callback-based: xsltSetSecurityPrefs registers an
 * xsltSecurityCheck function pointer per option.
 */

#ifndef __SECURITY_H__
#define __SECURITY_H__

#include <libxml/xmlversion.h>
#include <libxslt/xsltInternals.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef struct _xsltSecurityPrefs xsltSecurityPrefs;
typedef xsltSecurityPrefs *xsltSecurityPrefsPtr;

XMLPUBFUN int xsltSecurityAllow(xsltSecurityPrefsPtr sec,
                                xsltTransformContextPtr ctxt, const char *value);
XMLPUBFUN int xsltSecurityForbid(xsltSecurityPrefsPtr sec,
                                 xsltTransformContextPtr ctxt, const char *value);
XMLPUBFUN int xsltSetCtxtSecurityPrefs(xsltSecurityPrefsPtr sec,
                                       xsltTransformContextPtr ctxt);
XMLPUBFUN int xsltCheckRead(xsltSecurityPrefsPtr sec,
                            xsltTransformContextPtr ctxt, const xmlChar *URL);
XMLPUBFUN int xsltCheckWrite(xsltSecurityPrefsPtr sec,
                             xsltTransformContextPtr ctxt, const xmlChar *URL);

/**
 * xsltSecurityOption:
 *
 * The set of options that can be configured.
 */
typedef enum {
    XSLT_SECPREF_READ_FILE = 1,
    XSLT_SECPREF_WRITE_FILE,
    XSLT_SECPREF_CREATE_DIRECTORY,
    XSLT_SECPREF_READ_NETWORK,
    XSLT_SECPREF_WRITE_NETWORK
} xsltSecurityOption;

/**
 * xsltSecurityCheck:
 *
 * User-provided function to check the value of a string like a file
 * path or an URL. Returns non-zero to allow, 0 to deny.
 */
typedef int (*xsltSecurityCheck) (xsltSecurityPrefsPtr sec,
                                  xsltTransformContextPtr ctxt,
                                  const char *value);

/*
 * Module interfaces
 */
XSLTPUBFUN xsltSecurityPrefsPtr XSLTCALL
                xsltNewSecurityPrefs    (void);
XSLTPUBFUN void XSLTCALL
                xsltFreeSecurityPrefs   (xsltSecurityPrefsPtr sec);
XSLTPUBFUN int XSLTCALL
                xsltSetSecurityPrefs    (xsltSecurityPrefsPtr sec,
                                         xsltSecurityOption option,
                                         xsltSecurityCheck func);
XSLTPUBFUN xsltSecurityCheck XSLTCALL
                xsltGetSecurityPrefs    (xsltSecurityPrefsPtr sec,
                                         xsltSecurityOption option);

XSLTPUBFUN void XSLTCALL
                xsltSetDefaultSecurityPrefs (xsltSecurityPrefsPtr sec);
XSLTPUBFUN xsltSecurityPrefsPtr XSLTCALL
                xsltGetDefaultSecurityPrefs (void);

#ifdef __cplusplus
}
#endif

#endif /* __SECURITY_H__ */