| Crates.io | a2x |
| lib.rs | a2x |
| version | 0.1.2 |
| created_at | 2025-10-28 15:40:41.797305+00 |
| updated_at | 2025-11-20 14:51:10.486554+00 |
| description | A converter from ALFA to XACML policy language. |
| homepage | https://sr.ht/~gheartsfield/a2x/ |
| repository | https://sr.ht/~gheartsfield/a2x/ |
| max_upload_size | |
| id | 1904981 |
| size | 605,943 |
a2x converts policies written in the ALFA language to XACML 3.0 XML policies.
Licensed under the GNU General Public License v3.0 or later.
Please see the CHANGELOG for release history.
Convert any files in the src directory ending in .alfa to XACML,
saving to the xacml directory.
$ a2x --input src --output xacml
The --input option can be repeated for as many files or directories
as desired.
Most entities from the XACML spec are predefined and available through an implicitly imported namespace. To see a listing, run:
$ a2x --show-builtins
If you prefer to not have these implicitly imported, they can be
disabled with the --disable-builtins flag.
The default prefix for PolicySetId, PolicyId, and RuleId can be
customized with the --namespace option.
A sample policy is included in this
repository, which may be helpful as a reference for ALFA language
features, and a known working example for running a2x.
Convert the sample to XACML:
$ a2x -i samples -o xacml-gen
ALFA to XACML Converter v0.1.2
==============================
Input: samples
Output: xacml-gen
Scanning input directory...
Found 5 ALFA policy files
Parsing ALFA policies:
✓ samples/retail/attr.alfa
✓ samples/retail/oblig.alfa
✓ samples/retail/common.alfa
✓ samples/retail/main.alfa
⊘ samples/retail/empty.alfa (empty)
Writing XACML policies:
✓ xacml-gen/main.retail.xml
✓ xacml-gen/common.deny.xml
✓ xacml-gen/main.customerBusinessHours.xml
✓ xacml-gen/main.customerAddToCart.xml
✓ xacml-gen/main.clerkAddToCart.xml
✓ xacml-gen/main.voidTransaction.xml
Summary:
--------
ALFA files processed : 5
XACML files generated : 6
Policy Sets written : 3
Policies written : 7
Rules written : 9
Total time: 4.1ms
✓ Conversion completed successfully
a2x is written in Rust, so you will need to install Rust to compile it. Rust version 1.85.0 (stable) or newer is supported.
To build a2x:
$ git clone https://git.sr.ht/~gheartsfield/a2x
$ cd a2x
$ cargo build --release --locked
$ ./target/release/a2x --version
a2x 0.1.0
a2x has unit tests and full end-to-end tests that ensure ALFA policies are converted to exact matches of manually verified XACML policies. To run all these tests, use:
$ cargo test