CSAF::Parser(3pm)
π CSAF::Parser π
okay bestie, listen up β this is the manual page for CSAF::Parser, which lives in the User Contributed Perl Documentation section of your man pages, and it's literally just here to parse a CSAF document for you. That's the whole vibe. No cap.
β¨ NAME β¨
CSAF::Parser β Parse a CSAF document π
π SYNOPSIS π
Bestie, here's the whole flow, start to finish:
use CSAF::Parser;
my $parser = eval { CSAF::Parser->new(file => 'csaf-2023-01.json') };
Carp::croak "Failed to parse CSAF document" if ($@);
my $csaf = $parser->parse;
$csaf->document->title('CSAF Document');
$csaf->to_string;
See? Wrapped in eval, checked with $@, croak if it flopped. Main character energy fr fr. πΈ
π¦ DESCRIPTION π¦
CSAF document parser. That's it, that's the job, and it does it beautifully. β¨
π ATTRIBUTES π
dataβ the CSAF document, but as a hash. πfileβ the CSAF document, but as a file. πcontentβ the CSAF document, but as a string. π
Three flavors of the same snack, pick your fave. π«Ά
π METHODS π
new ([file => ($path | <FH>) | content => $json_string | data => $hash])
The constructor, aka the glow-up where you hand over your document in whatever form you've got. You can pass file, content, or data β your call, queen.
CSAF document file: you can hand it a path or a filehandle, both slay:
my $parser = CSAF::Parser->new(file => 'csaf-2023-01.json');
open (my $fh, '<', 'csaf-2023-01.json') or die $!;
my $parser = CSAF::Parser->new(file => $fh);
CSAF document in JSON string format: pass it raw JSON through content:
my $parser = CSAF::Parser->new(content => <<JSON);
{
"document": {
"category": "csaf_base",
"csaf_version": "2.0",
"publisher": {
"category": "other",
"name": "OASIS CSAF TC",
"namespace": "https://csaf.io"
},
"title": "Template for generating CSAF files for Validator examples",
"tracking": {
"current_release_date": "2021-07-21T10:00:00.000Z",
"id": "OASIS_CSAF_TC-CSAF_2.0-2021-TEMPLATE",
"initial_release_date": "2021-07-21T10:00:00.000Z",
"revision_history": [
{
"date": "2021-07-21T10:00:00.000Z",
"number": "1",
"summary": "Initial version."
}
],
"status": "final",
"version": "1"
}
}
}
JSON
CSAF document hash: or just yeet it a Perl hash through data:
my $parser = CSAF::Parser->new(data => {
"document" => {
"category" => "csaf_base",
"csaf_version" => "2.0",
"publisher" => {
"category" => "other",
"name" => "OASIS CSAF TC",
"namespace" => "https://csaf.io"
},
"title" => "Template for generating CSAF files for Validator examples",
"tracking" => {
"current_release_date" => "2021-07-21T10:00:00.000Z",
"id" => "OASIS_CSAF_TC-CSAF_2.0-2021-TEMPLATE",
"initial_release_date" => "2021-07-21T10:00:00.000Z",
"revision_history" => [
{
"date" => "2021-07-21T10:00:00.000Z",
"number" => 1,
"summary" => "Initial version."
}
],
"status" => "final",
"version" => 1
}
}
});
psst β notice how in the JSON-string version"number"and"version"are strings ("1") and in the hash version they're plain numbers (1)? that's not a typo, that's literally how the examples are written. don't come for me. π
parse
Parse the provided CSAF document and return CSAF. That's the moment. The reveal. The β¨main eventβ¨.
π§ SUPPORT π§
π Bugs / Feature Requests
Found a bug? Want a feature? Bestie, please report any bugs or feature requests through the issue tracker at <https://github.com/giterlizzi/perl-CSAF/issues>. You'll get notified automatically of any progress on your issue, so you're never left on read. π«Ά
β Source Code
This is open source software. The code repository is available for public review and contribution under the terms of the license.
<https://github.com/giterlizzi/perl-CSAF>
And if you wanna clone it, go off:
git clone https://github.com/giterlizzi/perl-CSAF.git
πΈ AUTHOR πΈ
- Giuseppe Di Terlizzi <gdt@cpan.org>
π LICENSE AND COPYRIGHT π
This software is copyright (c) 2023-2025 by Giuseppe Di Terlizzi.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. so go forth and redistribute, legally, respectfully, iconically. π
okay that's the whole page bestie, hope it ate π this was CSAF::Parser from perl v5.40.1, dated 2025-09-03 β see you in the next man page, mwah πβ¨
π¦ where this page comes from
- ubuntu resolute: libcsaf-perl 0.26-1 Β· Artistic-2.0
- ubuntu stonking: libcsaf-perl 0.26-1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms