This file is indexed.

/usr/share/perl5/Octopussy/Plugin.pm is in octopussy 1.0.6-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# $HeadURL$
# $Revision: 552 $
# $Date: 2012-02-17 00:05:15 +0000 (Fri, 17 Feb 2012) $
# $Author: sebthebert $

=head1 NAME

Octopussy::Plugin - Octopussy Plugin module

=cut

package Octopussy::Plugin;

use strict;
no strict 'refs';
use warnings;
use Readonly;

use AAT::FS;
use AAT::Syslog;
use AAT::Utils qw( ARRAY );
use AAT::XML;
use Octopussy::FS;

Readonly my $DIR_PLUGIN         => 'plugins';
Readonly my $DIR_PLUGIN_MODULES => (-d '/usr/share/perl5/Octopussy/Plugin/' 
	? '/usr/share/perl5/Octopussy/Plugin/' 
	: $Config::Config{installsitelib} . '/Octopussy/Plugin/');

my $dir_plugins     = undef;
my %function_source = ();

BEGIN
{
	Readonly my $DIR_PLUGIN_MODULES => (-d '/usr/share/perl5/Octopussy/Plugin/' 
	? '/usr/share/perl5/Octopussy/Plugin/' 
	: $Config::Config{installsitelib} . '/Octopussy/Plugin/');
  if (defined opendir DIR, $DIR_PLUGIN_MODULES)
  {
  	my @plugins = grep { /.+\.pm$/ } readdir DIR;
  	foreach my $p (@plugins)
  	{
    	if ("Octopussy/Plugin/$p" =~ /^(Octopussy\/Plugin\/)(.+\.pm)$/)
    	{
			my $file_module = "$1$2";
			eval 
			{
      			require $file_module;    ## no critic
				1;
			}
			or do 
			{
				AAT::Syslog::Message('octopussy', 'UNABLE_LOAD_PLUGIN_MODULE', 
					$file_module);
			}
    	}
  	}
  	closedir DIR;
  }
}

=head1 FUNCTIONS

=head2 Init_All(\%conf)

=cut

sub Init_All
{
  my $conf = shift;

  my @plugins = AAT::FS::Directory_Files($DIR_PLUGIN_MODULES, qr/.+\.pm$/);
  foreach my $p (@plugins)
  {
    $p =~ s/\.pm$//;
    my $func = 'Octopussy::Plugin::' . $p . '::Init';
    &{$func}($conf);
  }

  return (scalar @plugins);
}

=head2 Init(\%conf, @plugins)

=cut

sub Init
{
  my ($conf, @plugins) = @_;
  my %done = ();

  foreach my $p (@plugins)
  {
    if (($p =~ /Octopussy::Plugin::(.+?)::/) && (!defined $done{$1}))
    {
      my $func = 'Octopussy::Plugin::' . $1 . '::Init';
      $done{$1} = 1;
      &{$func}($conf);
    }
  }

  return (scalar(keys %done));
}

=head2 List()

Returns List of Plugins

=cut

sub List
{
  $dir_plugins ||= Octopussy::FS::Directory($DIR_PLUGIN);

  return (AAT::XML::Name_List($dir_plugins));
}

=head2 Functions()

Returns List of Plugins Functions

=cut

sub Functions
{
  my @functions = ();

  $dir_plugins ||= Octopussy::FS::Directory($DIR_PLUGIN);
  my @files = AAT::FS::Directory_Files($dir_plugins, qr/.+\.xml$/);
  foreach my $f (@files)
  {
    my $conf = AAT::XML::Read("$dir_plugins/$f");
    push @functions, {plugin => $conf->{name}, functions => $conf->{function}}
      if (defined $conf->{function});
  }

  return (@functions);
}

=head2 Function_Source($fct)

=cut

sub Function_Source
{
  my $fct = shift;

  if ($fct =~ /Octopussy::Plugin::(.+)::.+$/)
  {
    my $mod = $1;
    if (!defined $function_source{$fct})
    {
      $dir_plugins ||= Octopussy::FS::Directory($DIR_PLUGIN);
      my $conf = AAT::XML::Read("$dir_plugins/$mod.xml");
      foreach my $pf (ARRAY($conf->{function}))
      {
        $function_source{$fct} = $pf->{source} if ($pf->{perl} eq $fct);
      }
      $function_source{$fct} = 'OUTPUT' if (!defined $function_source{$fct});
    }
  }

  return ($function_source{$fct});
}

=head2 SQL_Convert($str)

Returns Plugin Function to SQL
Octopussy::Plugin::Function(field) -> Plugin_Function__field

=cut

sub SQL_Convert
{
  my $str = shift;

  if ($str =~ /^(\S+::\S+?)\((\S+)\)$/)
  {
    my ($fct, $field) = ($1, $2);
    $fct =~ s/^Octopussy:://;
    $fct =~ s/::/_/g;
    return ("${fct}__${field}");
  }
  else
  {
    return ($str);
  }
}

=head2 Field_Data

=cut

sub Field_Data
{
  my ($line, $long_field) = @_;
  my $result = undef;

  if ($long_field =~ /^(\S+::\S+?)\((\S+)\)$/)
  {
    my ($plugin, $field) = ($1, $2);
    if (Function_Source($plugin) eq 'OUTPUT')
    {
      $result = &{$plugin}($line->{$field});
    }
    else
    {
      my $plugin_sql = SQL_Convert($long_field);
      $result = $line->{$plugin_sql};
    }
  }

  return ($result);
}

1;

=head1 AUTHOR

Sebastien Thebert <octo.devel@gmail.com>

=cut