CSAF::Parser(3pm)

πŸ“¦
version 0.26 Β· 2 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– 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>

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