Skip to content

Commit b8bd9f6

Browse files
committed
prevent property dump in message logs
1 parent 46eeb17 commit b8bd9f6

File tree

5 files changed

+24
-9
lines changed

5 files changed

+24
-9
lines changed

src-admintool/config/reports.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,12 @@ producer_files:
120120
category: files
121121
description: |
122122
Producer Files for a Mnemonic.
123-
s3-list:
124-
link-title: S3 Download Links
123+
daily-build-s3-list:
124+
link-title: Daily Build Links
125125
breadcrumb: bp_content_projects
126126
class: S3ListQuery
127127
category: files
128+
params: ['daily-build', 'build-log.status.txt']
128129
description: |
129130
Generate S3 Download Links for an S3 prefix.
130131

src-admintool/queries/s3_list_query.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44

55
# Query class - see config/reports.yml for description
66
class S3ListQuery < AdminQuery
7-
def initialize(query_factory, path, myparams)
7+
def initialize(query_factory, path, myparams, rptpath, status_file)
88
super(query_factory, path, myparams)
9-
rptpath = myparams.fetch('rptpath', 'daily-build')
10-
status_file = myparams.fetch('status-file', '')
119
@report = "merritt-reports/#{rptpath}"
1210
@files = []
1311
@status = 'SKIP'
@@ -21,7 +19,7 @@ def initialize(query_factory, path, myparams)
2119
@status = resp.body.read.chop
2220
end
2321
rescue StandardError
24-
LambdaBase.log_config(config, "#{@report}/#{status_file} does not exist")
22+
LambdaBase.log_config(@config, "#{@report}/#{status_file} does not exist")
2523
end
2624

2725
resp = @s3_client.list_objects_v2({
@@ -49,4 +47,4 @@ def run_sql
4947
def init_status
5048
:PASS
5149
end
52-
end
50+
end

src-admintool/web/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ <h3>Bytes Recently Ingested</h3>
8181

8282
<h3>Daily Build Output</h3>
8383
<ul>
84-
<li class="graph"><a href="{{ADMINTOOL_HOME}}?path=s3-list&rptpath=daily-build&status-file=build-log.status.txt">Daily Build</a></li>
84+
<li class="graph"><a href="{{ADMINTOOL_HOME}}?path=daily-build-s3-list">Daily Build</a></li>
8585
</ul>
8686

8787
<h3>Object Management</h3>

src-common/lambda_base.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ def initialize(config, event = {}, client_context = {})
4444
read_cognito_token(event)
4545
end
4646

47+
# exception message strings were including a dump of object properties
48+
# this was leaking data to opersearch.
49+
# this prevents any object (including MySql2::Client) from dumping properties
50+
def inspect
51+
"#{self.class} (property listing suppressed)"
52+
end
53+
4754
def read_cognito_token(event)
4855
cognito_token = event.fetch('headers', {}).fetch('x-amzn-oidc-accesstoken', '')
4956
if cognito_token.empty?
@@ -337,3 +344,12 @@ def self.log(message)
337344
log_config({}, message)
338345
end
339346
end
347+
348+
# prevent logging credentials to opensearch
349+
class Object
350+
def inspect
351+
def inspect
352+
"#{self.class} (property listing suppressed)"
353+
end
354+
end
355+
end

src-common/template/navmenu.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<a class="graph" href="{{ADMINTOOL_HOME}}?path=ingest_bytes_by_hour&days=30">Recent Bytes ingested by day - last 30 days</a>
2525
<a class="graph" href="{{ADMINTOOL_HOME}}?path=ingest_bytes_by_week">Recent Bytes ingested by week - last year</a>
2626
<a class="graph" href="{{ADMINTOOL_HOME}}?path=list_collections">List Collections</a>
27-
<a class="graph" href="{{ADMINTOOL_HOME}}?path=s3-list&rptpath=daily-build&status-file=build-log.status.txt">Daily Build Output</a>
27+
<a class="graph" href="{{ADMINTOOL_HOME}}?path=daily-build-s3-list">Daily Build Output</a>
2828
</div>
2929
</div>
3030
<div class="dropdown">

0 commit comments

Comments
 (0)