mirror of https://github.com/MISP/MISP
Using json parser to parse json configuration output from cake
parent
2bccfb027e
commit
1115a7fe53
|
@ -28,6 +28,8 @@ use strict;
|
|||
use warnings;
|
||||
use File::Path qw(make_path);
|
||||
|
||||
use JSON;
|
||||
|
||||
my $misp_user="www-data";
|
||||
my $misp_path="/usr/share/misp";
|
||||
my $misp_config_path="/etc/misp/";
|
||||
|
@ -106,24 +108,16 @@ if ($create) {
|
|||
close $internalfh;
|
||||
}
|
||||
|
||||
die "foo";
|
||||
my $settings = `sudo -u $misp_user $misp_path/app/Console/cake admin getSetting all`;
|
||||
my @lines = split("\n",$settings);
|
||||
my $value = 0;
|
||||
my $setting = 0;
|
||||
foreach(@lines) {
|
||||
if ($_ =~ m/\"value\": (.*)/) {
|
||||
$value = substr $1, 0, -1;
|
||||
}
|
||||
if ($_ =~ m/\"setting\": \"(.*)\"/) {
|
||||
$setting = $1;
|
||||
}
|
||||
if ($value && $setting) {
|
||||
#print "$setting -> $value\n";
|
||||
my $settings = `sudo -u $misp_user $misp_path/app/Console/cake admin getSetting all | tail -n +7`;
|
||||
my $jsonconfig = decode_json($settings);
|
||||
|
||||
foreach my $item (@$jsonconfig) {
|
||||
my $setting = $item->{'setting'};
|
||||
my $value = $item->{'value'};
|
||||
|
||||
my $category = "";
|
||||
my $key = "";
|
||||
my $section = "";
|
||||
|
||||
# Plugin.S3_aws_secret_key -> false
|
||||
# ^ ^
|
||||
# | |- Section (S3)
|
||||
|
@ -163,11 +157,6 @@ if ($create) {
|
|||
open(my $fh, ">>", "$conf_to_write");
|
||||
print $fh "#$key $value\n";
|
||||
close $fh;
|
||||
|
||||
# Unset those two variables to be filled again!
|
||||
$value = 0;
|
||||
$setting = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue