Skip to content

Commit e72213d

Browse files
author
A. Nick Georgieff
committed
3.5.5
1 parent bef3ba8 commit e72213d

File tree

21,108 files changed

+74641
-2456411
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

21,108 files changed

+74641
-2456411
lines changed

bin/fix_task.pl

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env perl
2+
3+
use MongoDB;
4+
use Data::Dumper;
5+
use v5.18;
6+
7+
my $mongo = MongoDB->connect->db('scot-prod');
8+
my $collection = $mongo->get_collection('entry');
9+
my $cursor = $collection->find({class => "task"});
10+
11+
print "starting...\n";
12+
print $cursor->count . " task records\n";
13+
my %lookup = ();
14+
15+
while (my $task = $cursor->next) {
16+
17+
my $id = $task->{id};
18+
print "...task $id\n";
19+
20+
my $meta = $task->{metadata};
21+
22+
if ( defined $meta ) {
23+
24+
if ( defined $meta->{status}
25+
&& defined $meta->{when}
26+
&& defined $meta->{who} ) {
27+
28+
say "... ... has valid task meta structure";
29+
30+
my $thref = {
31+
status => $meta->{status},
32+
when => $meta->{when},
33+
who => $meta->{who},
34+
};
35+
36+
delete $meta->{status};
37+
delete $meta->{when};
38+
delete $meta->{who};
39+
40+
$meta->{task} = $thref;
41+
42+
my $set = {
43+
metadata => $meta
44+
};
45+
46+
$collection->update_one(
47+
{id => $id},
48+
{'$set' => $set }
49+
);
50+
say "Update == ".Dumper($set);
51+
}
52+
}
53+
}

install/src/mongodb/reset.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ db.signature.drop();
2222
db.sigbody.drop();
2323
db.apikey.drop();
2424
db.handler.drop();
25+
db.stat.drop();
2526

2627
print ("Creating indexes...");
2728
load("./src/mongodb/indexes.js");

install/src/scot/scot.cfg.pl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@
6363
log_level => 'DEBUG',
6464
},
6565

66+
cgi_ids_config => {
67+
whitelist_file => '',
68+
disable_filters => [],
69+
},
70+
6671
# modules to instantiate at Env.pm startup. will be done in
6772
# order of the array
6873
modules => [

lib/Scot/App/Flair.pm

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,36 @@ sub _get_img_munger {
8383
return $env->img_munger;
8484
};
8585

86-
#has scot => (
87-
# is => 'ro',
88-
# isa => 'Scot::Util::Scot2',
89-
# required => 1,
90-
# lazy => 1,
91-
# builder => '_build_scot_scot',
92-
#);
93-
94-
#sub _build_scot_scot {
95-
# my $self = shift;
96-
# my $env = shift;
97-
# return $env->scot;
98-
#}
86+
has stomp_host => (
87+
is => 'ro',
88+
isa => 'Str',
89+
required => 1,
90+
lazy => 1,
91+
builder => '_build_stomp_host',
92+
);
93+
94+
sub _build_stomp_host {
95+
my $self = shift;
96+
my $attr = "stomp_host";
97+
my $default = "localhost";
98+
my $envname = "scot_util_stomphost";
99+
return $self->get_config_value($attr, $default, $envname);
100+
}
101+
has stomp_port => (
102+
is => 'ro',
103+
isa => 'Int',
104+
required => 1,
105+
lazy => 1,
106+
builder => '_build_stomp_port',
107+
);
108+
109+
sub _build_stomp_port {
110+
my $self = shift;
111+
my $attr = "stomp_port";
112+
my $default = 61613;
113+
my $envname = "scot_util_stompport";
114+
return $self->get_config_value($attr, $default, $envname);
115+
}
99116

100117
has interactive => (
101118
is => 'ro',
@@ -156,7 +173,14 @@ sub run {
156173
my $self = shift;
157174
my $log = $self->log;
158175
my $pm = AnyEvent::ForkManager->new(max_workers => $self->max_workers);
159-
my $stomp = AnyEvent::STOMP::Client->new();
176+
my $stomp;
177+
178+
if ( $self->stomp_host ne "localhost" ) {
179+
$stomp = AnyEvent::STOMP::Client->new($self->stomp_host, $self->stomp_port);
180+
}
181+
else {
182+
$stomp = AnyEvent::STOMP::Client->new;
183+
}
160184

161185
$stomp->connect();
162186
$stomp->on_connected(sub {
@@ -384,6 +408,7 @@ sub flair_record {
384408

385409
if ( $column =~ /^message[_-]id$/i ) {
386410
# the data is telling us that this is a email message_id, so flair
411+
$value =~ s/[\<\>]//g; # cut out the < > brackets if they exist
387412
my ($eref, $flair) = $self->process_cell($value, "message_id");
388413
if ( ! defined $seen{$eref->{value}} ) {
389414
push @entity, $eref;
@@ -409,7 +434,15 @@ sub flair_record {
409434
# each link in this field is a <div>filename</div>,
410435
$log->debug("A File attachment Column detected!");
411436
$log->debug("value = ",{filter=>\&Dumper, value=>$value});
437+
438+
if ( $value eq "" || $value eq " " ) {
439+
next VALUE;
440+
}
412441

442+
if ( $value eq "" || $value eq " " ) {
443+
next VALUE;
444+
}
445+
413446
my ($eref, $flair) = $self->process_cell($value, "filename");
414447
if ( ! defined $seen{$eref->{value}} ) {
415448
push @entity, $eref;
@@ -464,6 +497,8 @@ sub process_cell {
464497
my $log = $self->env->log;
465498

466499
$log->debug("text = $text");
500+
$text = encode_entities($text);
501+
$log->debug("encoded text = $text");
467502
$log->debug("header = $header");
468503
my $flair = $self->genspan($text,$header);
469504
$log->debug("text = $text");

lib/Scot/App/Stretch.pm

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,37 @@ sub _get_max_workers {
9595
return $self->get_config_value($attr, $default, $envname);
9696
}
9797

98+
has stomp_host => (
99+
is => 'ro',
100+
isa => 'Str',
101+
required => 1,
102+
lazy => 1,
103+
builder => '_build_stomp_host',
104+
);
105+
106+
sub _build_stomp_host {
107+
my $self = shift;
108+
my $attr = "stomp_host";
109+
my $default = "localhost";
110+
my $envname = "scot_util_stomphost";
111+
return $self->get_config_value($attr, $default, $envname);
112+
}
113+
has stomp_port => (
114+
is => 'ro',
115+
isa => 'Int',
116+
required => 1,
117+
lazy => 1,
118+
builder => '_build_stomp_port',
119+
);
120+
121+
sub _build_stomp_port {
122+
my $self = shift;
123+
my $attr = "stomp_port";
124+
my $default = 61613;
125+
my $envname = "scot_util_stompport";
126+
return $self->get_config_value($attr, $default, $envname);
127+
}
128+
98129
=head2 Autonomous
99130
100131
$stretch->run();
@@ -112,7 +143,15 @@ sub run {
112143
$log->debug("Starting STOMP watcher");
113144
$log->debug("SCOT access mode is ".$self->scot_get_method);
114145

115-
my $stomp = AnyEvent::STOMP::Client->new();
146+
my $stomp;
147+
148+
if ( $self->stomp_host eq "localhost" ) {
149+
$stomp = AnyEvent::STOMP::Client->new();
150+
}
151+
else {
152+
$stomp = AnyEvent::STOMP::Client->new($self->stomp_host, $self->stomp_port);
153+
}
154+
116155
my $pm = AnyEvent::ForkManager->new(
117156
max_workers => $self->max_workers
118157
);
@@ -182,7 +221,7 @@ sub process_message {
182221
my $cleanser = Data::Clean::FromJSON->get_cleanser;
183222
my $record = $self->get_document($type, $id);
184223
$cleanser->clean_in_place($record);
185-
$es->index($type, $record, 'scot');
224+
$es->index('scot', $type, $record);
186225
$self->put_stat("elastic doc inserted", 1);
187226
}
188227

@@ -291,7 +330,7 @@ sub process_all {
291330

292331
delete $href->{_id};
293332
try {
294-
$es->index($collection, $href, 'scot');
333+
$es->index('scot',$collection, $href);
295334
}
296335
catch {
297336
say "Error: Failed to index $collection : ". $href->{id};

lib/Scot/Collection.pm

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ has env => (
2424
default => sub { Scot::Env->instance; },
2525
);
2626

27+
28+
2729
=item B<create(%args)>
2830
2931
replacing Meerkat's create with one that will generate a integer id.
@@ -518,7 +520,8 @@ sub api_list {
518520

519521
if ( $href->{task_search} ) {
520522
# $match->{'task.status'} = {'$exists' => 1};
521-
$match->{'metadata.status'} = {'$exists' => 1};
523+
# $match->{'metadata.status'} = {'$exists' => 1};
524+
$match->{class} = "task";
522525
}
523526

524527
$self->env->log->debug("match is ",{filter=>\&Dumper, value=>$match});
@@ -624,7 +627,13 @@ sub api_find {
624627
my $obj = $self->find_iid($id);
625628
return $obj;
626629
}
627-
my $id = $href->{id} + 0;
630+
my $id = $href->{id};
631+
if ( $id eq "undefined" ) {
632+
$id = 0;
633+
}
634+
else {
635+
$id += 0;
636+
}
628637
my $obj = $self->find_iid($id);
629638
return $obj;
630639

lib/Scot/Collection/Apikey.pm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ override api_list => sub {
4040
my $req = shift;
4141
my $user = shift;
4242
my $groups = shift;
43+
my $env = $self->env;
4344

4445
my $match = $self->build_match_ref($req->{request});
4546

46-
if (! $self->env->is_admin($user,$groups) ) {
47+
if (! $env->is_admin($user,$groups) ) {
4748
$match->{username} = $user;
4849
}
4950
my $cursor = $self->find($match);

lib/Scot/Collection/Audit.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ sub create_audit_rec {
3131
groups => $handler->session('groups'),
3232
when => $self->env->now,
3333
method => $req->method,
34-
url => $req->url->to_abs,
34+
url => $req->url->to_abs->to_string,
3535
from => $handler->tx->remote_address,
3636
agent => $req->headers->user_agent,
3737
params => $req->params->to_hash,

0 commit comments

Comments
 (0)