{"id":16102394,"url":"https://github.com/sshaw/ncftpd-log-parse","last_synced_at":"2025-04-06T01:11:54.316Z","repository":{"id":136718215,"uuid":"1499054","full_name":"sshaw/NcFTPd-Log-Parse","owner":"sshaw","description":"Parse NcFTPd xfer, session, and misc logs","archived":false,"fork":false,"pushed_at":"2011-04-26T06:44:42.000Z","size":116,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-12T06:59:43.856Z","etag":null,"topics":["ftp","ftp-server","logs","ncftp","parser","perl"],"latest_commit_sha":null,"homepage":"","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sshaw.png","metadata":{"files":{"readme":"README.pod","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-03-19T04:10:25.000Z","updated_at":"2017-06-02T00:52:38.000Z","dependencies_parsed_at":"2023-07-14T12:30:40.602Z","dependency_job_id":null,"html_url":"https://github.com/sshaw/NcFTPd-Log-Parse","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshaw%2FNcFTPd-Log-Parse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshaw%2FNcFTPd-Log-Parse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshaw%2FNcFTPd-Log-Parse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sshaw%2FNcFTPd-Log-Parse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sshaw","download_url":"https://codeload.github.com/sshaw/NcFTPd-Log-Parse/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247419871,"owners_count":20936013,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ftp","ftp-server","logs","ncftp","parser","perl"],"created_at":"2024-10-09T18:53:43.491Z","updated_at":"2025-04-06T01:11:54.293Z","avatar_url":"https://github.com/sshaw.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"=head1 NAME\r\n\r\nNcFTPd::Log::Parse - parse NcFTPd xfer, session, and misc logs\r\n\r\n=head1 SYNOPSIS\r\n\r\n  use NcFTPd::Log::Parse;\r\n  $parser = NcFTPd::Log::Parse-\u003enew(xfer =\u003e 'xfer.20100101'); # Parse a xfer log\r\n  $parser = NcFTPd::Log::Parse::Xfer-\u003enew('xfer.20100101');   # Same as above\r\n\r\n  while($line = $parser-\u003enext) {\r\n    if($line-\u003e{operation} eq 'S') {\r\n      print 'Upload';  \r\n      $line-\u003e{pathname};\r\n      $line-\u003e{size};\r\n      # ... \r\n    }\r\n  }\r\n\r\n  # Check for an error, otherwise it was EOF\r\n  if($parser-\u003eerror) {\r\n    die 'Parsing failed: ' . $parser-\u003eerror;\r\n  }\r\n\r\n  $parser = NcFTPd::Log::Parse-\u003enew(xfer   =\u003e 'xfer.20100101', \r\n\t\t\t\t    expand =\u003e 1,  \t    \r\n\t\t\t\t    filter =\u003e sub { $_-\u003e{user} eq 'sshaw' });\r\n  $line = $parser-\u003enext;\r\n  $line-\u003e{operation}   # Expanded 'S' to 'store'\r\n  $line-\u003e{notes}       # Expanded 'SfPs' to ['Used sendfile', 'PASV connection']\r\n\r\n  # Load parser based on the log's name (using NcFTPd's default log names)\r\n  $parser = NcFTPd::Log::Parse-\u003enew('xfer.20100101');  \r\n  $parser = NcFTPd::Log::Parse-\u003enew('session.20100101'); \r\n  \r\n=head1 DESCRIPTION\r\n \r\nThe C\u003cNcFTPd::Log::Parse\u003e package is composed of 3 parsers:\r\n\r\n=over 2\r\n\r\n=item L\u003cNcFTPd::Log::Parse::Xfer\u003e\r\n\r\n=item L\u003cNcFTPd::Log::Parse::Misc\u003e\r\n\r\n=item L\u003cNcFTPd::Log::Parse::Session\u003e\r\n\r\n=back\r\n\r\nA parser can be created via the factory class C\u003cNcFTPd::Log::Parse\u003e:\r\n\r\n    $parser = NcFTPd::Log::Parse-\u003enew(xfer =\u003e 'ftp.log')\r\n\r\nOr it can be created directly:\r\n\r\n    $parser = NcFTPd::Log::Parse::Xfer-\u003enew('ftp.log')\r\n\r\nOptions can be provided to both calls to L\u003c\u003c C\u003cnew\u003e|/new \u003e\u003e via a hash:\r\n\r\n    $parser = NcFTPd::Log::Parse-\u003enew(xfer   =\u003e 'ftp.log', \r\n\t\t\t\t      expand =\u003e 1, \r\n\t\t\t\t      filter =\u003e sub { ... })\r\n\r\nLines are parsed on demand by calling the L\u003c\u003c C\u003cnext\u003e|/next \u003e\u003e method:\r\n\r\n    $entry = $parser-\u003enext\r\n\r\nEach call to C\u003cnext\u003e returns a hash reference. \r\n\r\nOn error and EOF C\u003cundef\u003e is returned. In order to discern between the two you must \r\ncheck the L\u003c\u003c C\u003cerror\u003e|/error \u003e\u003e method:\r\n\r\n    if($parser-\u003eerror) {\r\n       # it wasn't EOF\r\n    } \r\n \r\n=head1 METHODS\r\n\r\n=head2 new\r\n\r\nCreate a parser capable of parsing the specified file. The file must be a path to \r\na NcFTPd misc, session, or xfer file:\r\n\r\n    $parser = NcFTPd::Log::Parse-\u003enew($file, %options)\r\n    $parser = NcFTPd::Log::Parse-\u003enew(xfer =\u003e $file, %options)\r\n\r\n=head3 Returns\r\n\r\nA parser capable of parsing the specified file. \r\n\r\n=head3 Arguments\r\n\r\nC\u003c$file\u003e\r\n\r\nThe file to parse can be given as a single argument:\r\n\r\n    $parser = NcFTPd::Log::Parse-\u003enew('session.log', %options)\r\n\r\nOr as a part of the options hash, where the key is the log type and the value is the path to a log:\r\n\r\n    $parser = NcFTPd::Log::Parse-\u003enew(xfer =\u003e 'ftp.log', %options);    \r\n\r\nWhen C\u003c$file\u003e is given as a single argument an attempt is made to create the correct \r\nparser based on the filename's prefix. These prefixes are based on NcFTPd defaults.\r\n\r\nC\u003c%options\u003e\r\n\r\n=over 4\r\n\r\n=item * C\u003c\u003c xfer =\u003e $file \u003e\u003e\r\n\r\nCreate a L\u003cxfer log parser|NcFTPd::Log::Parse::Xfer\u003e for the given file\r\n\r\n=item * C\u003c\u003c sess =\u003e $file \u003e\u003e\r\n\r\n=item * C\u003c\u003c session =\u003e $file \u003e\u003e \r\n\r\nCreate a L\u003csession log parser|NcFTPd::Log::Parse::Session\u003e for the given file\r\n\r\n=item * C\u003c\u003c misc =\u003e $file \u003e\u003e \r\n\r\nCreate a L\u003cmisc log parser|NcFTPd::Log::Parse::Misc\u003e for the given file\r\n\r\n=item * C\u003c\u003c filter =\u003e sub { ... } \u003e\u003e\r\n\r\nOnly return entries that match the filter. By default all entries are returned. \r\n\r\nIf the sub reference returns true the entry will be kept, otherwise it's skipped and\r\nthe next line in the file is parsed. The current entry is provided to the sub as a hash reference (its parsed form) via the C\u003c$_\u003e variable:\r\n\r\n    filter =\u003e sub { \r\n\t# Uploads by a_user\r\n        $_-\u003e{user} eq 'a_user' \u0026\u0026\r\n\t$_-\u003e{operation} eq 'S'\r\n    }\r\n\r\n=item * C\u003c\u003c expand =\u003e 1|0 \u003e\u003e \r\n\r\n=item * C\u003c\u003c expand =\u003e [ 'field1', 'field2', ... ] \u003e\u003e \r\n\r\nExpand all \"expandable\" entries, or just the \"expandable\" entries named in the array reference. \r\nDefaults to C\u003c0\u003e, no entries are expanded.\r\n\r\nA few types of log entries have cryptic fields. This option will expand these to something you can understand without having\r\nto refer to the NcFTPd docs. A value of C\u003c1\u003e will expand all \"expandable\" fields, C\u003c0\u003e will not expand any.  \r\nYou can also provide an C\u003cARRAY\u003e ref containing fields to expand. \r\n\r\nCheck the parser specific documentation to see what's expanded.\r\n\r\n=back\r\n\r\n=head3 Errors\r\n\r\nIf a parser cannot be created an error will be raised. \r\n\r\n=head2 next\r\n\r\nParse and return the next entry in the log or, if a C\u003cfilter\u003e been provided, the next entry matching the filter. \r\n\r\n=head3 Returns\r\n\r\nOn success a hash reference is returned. The keys are dependent upon the type of log being parsed, see the \r\nL\u003clog specific parser documentation|/NcFTPd::Log::Parse::Xfer\u003e for details. \r\n\r\nOn error C\u003cundef\u003e is returned. Call L\u003c\u003c C\u003cerror\u003e|/error \u003e\u003e retrieve the reason for the failure.\r\n\r\n=head3 Arguments\r\n\r\nNone\r\n\r\n=head2 error\r\n  \r\nEnquire why the last call to  L\u003c\u003c C\u003cnext\u003e|/next \u003e\u003e failed. \r\n\r\n=head3 Returns\r\n\r\nA string containing the error or an empty string if there wasn't an error.\r\n\r\n=head3 Arguments\r\n\r\nNone\r\n\r\n=head1 SEE ALSO\r\n\r\nL\u003cNcFTPd::Log::Parse::Xfer\u003e, L\u003cNcFTPd::Log::Parse::Session\u003e, L\u003cNcFTPd::Log::Parse::Misc\u003e and \r\nthe NcFTPd documentation L\u003chttp://ncftpd.com/ncftpd/doc/misc\u003e\r\n\r\n=head1 AUTHOR\r\n\r\nSkye Shaw \u003csshaw AT lucas.cis.temple.edu\u003e\r\n\r\n=head1 COPYRIGHT\r\n\r\nCopyright (C) 2011 Skye Shaw\r\n\r\nThis program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsshaw%2Fncftpd-log-parse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsshaw%2Fncftpd-log-parse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsshaw%2Fncftpd-log-parse/lists"}