Sh3ll
OdayForums


Server : Apache
System : Linux server1.cgrithy.com 3.10.0-1160.95.1.el7.x86_64 #1 SMP Mon Jul 24 13:59:37 UTC 2023 x86_64
User : nobody ( 99)
PHP Version : 8.1.23
Disable Function : NONE
Directory :  /usr/local/bin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/local/bin/metabase-profile
#!/usr/bin/perl
use 5.006;
use strict;
use warnings;

package metabase_profile; # dzil needs this
# PODNAME: metabase-profile
# ABSTRACT: create a metabase profile

our $VERSION = '0.025';

use Getopt::Long;
use JSON::MaybeXS ();
use Metabase::User::Profile;
use Metabase::User::Secret;
use Pod::Usage;
use IO::Prompt::Tiny qw(prompt);

my ( %profile, $help, $output, $full_name, $email_address, $password );
my $result = GetOptions(
    'help|h'     => \$help,
    'output|o:s' => \$output,
    'name:s'     => \$full_name,
    'email:s'    => \$email_address,
    'secret:s'   => \$password,
);

pod2usage( { -verbose => 2 } ) if !$result || $help;

# setup output file and confirm it doesn't exist
if ( !defined $output ) {
    $output = "metabase_id.json";
}
if ( -f $output ) {
    die "Won't over-write existing '$output' file.  Aborting.\n";
}

# get profile information
$profile{full_name}     = $full_name     if defined $full_name;
$profile{email_address} = $email_address if defined $email_address;
$profile{password}      = $password      if defined $password;

my @prompts = (
    full_name     => 'full name',
    email_address => 'email address',
    password      => 'password/secret',
);

while (@prompts) {
    my ( $key, $phrase ) = splice( @prompts, 0, 2 );
    next if $profile{$key};
    chomp( my $answer = prompt("Enter $phrase\: ") );
    $profile{$key} = $answer;
}

# create profile and secret objects
$password = delete $profile{password};
my $profile = Metabase::User::Profile->create(%profile);
my $secret  = Metabase::User::Secret->new(
    resource => $profile->resource,
    content  => $password,
);

# write output
print "Writing profile to '$output'\n";
open my $fh, ">", $output;
print {$fh}
  JSON::MaybeXS->new(ascii => 1, pretty => 1)->encode( [ $profile->as_struct, $secret->as_struct, ] );
close $fh;
chmod 0600, $output;

__END__

=pod

=encoding UTF-8

=head1 NAME

metabase-profile - create a metabase profile

=head1 VERSION

version 0.025

=head1 SYNOPSIS

  $ metabase-profile
  Enter full name: John Doe
  Enter email address: jdoe@example.com
  Enter password/secret: zqxjkh
  Writing profile to 'metabase_id.json'

=head1 USAGE

The metabase-profile program makes it easy to create a user profile for
submitting facts and reports to a Metabase server.

Valid options include:

      --email   ADDRESS   user email address eg "jd@example.com"
      --name    FULLNAME  full user name, eg "John Doe"
  -o, --output  FILENAME  output filename
      --secret  PASSWORD  password for authentication
  -h, --help              print man page

If no output file name is given, the default name 'metabase_id.json' will be
used.  If the output filename (or default) exists, the program will abort
rather than overwrite the file.  The output file will be in JSON and contain
the user profile and the user's shared secret.

Typically, when a Metabase server first receives a report from a new user
profile, the shared secret is recorded and will be used to authenticate
subsequent submissions.  The output should not be shared publicly or
made group or world readable.

Use the resulting file according to the instructions of your Metabase
client program. You may wish to copy it across computers if you would like
to be identified consistently when submitting reports from different
locations.

=head1 AUTHORS

=over 4

=item *

David Golden <dagolden@cpan.org>

=item *

Ricardo Signes <rjbs@cpan.org>

=item *

H.Merijn Brand <hmbrand@cpan.org>

=back

=head1 COPYRIGHT AND LICENSE

This software is Copyright (c) 2016 by David Golden.

This is free software, licensed under:

  The Apache License, Version 2.0, January 2004

=cut

ZeroDay Forums Mini