diff options
author | Rob Stradling <rob@comodo.com> | 2017-10-20 12:11:49 +0100 |
---|---|---|
committer | Rob Stradling <rob@comodo.com> | 2017-10-20 12:11:49 +0100 |
commit | f44dfeda1d5fc991f5554bffb8306b25508e53f7 (patch) | |
tree | b7d9ad7752eef31790fa903ac4b0598c80f99cbc | |
parent | 2fb5b2056de1403625d66339063d65b75d2d34ac (diff) | |
download | certwatch_db-origin/HEAD.zip certwatch_db-origin/HEAD.tar.gz certwatch_db-origin/HEAD.tar.bz2 |
Add logs.json.HEADorigin/masterorigin/HEADmaster
-rw-r--r-- | web_apis.fnc | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/web_apis.fnc b/web_apis.fnc index 71d7c57..3fae3ed 100644 --- a/web_apis.fnc +++ b/web_apis.fnc @@ -225,6 +225,14 @@ BEGIN t_type := lower(t_outputType); t_title := t_type; t_outputType := 'html'; + ELSIF lower(t_outputType) LIKE '%.json' THEN + t_type := lower(t_outputType); + t_outputType := 'json'; + t_output := +'[BEGIN_HEADERS] +Content-Type: application/json +[END_HEADERS] +'; ELSIF lower(t_outputType) IN ('revoked-intermediates', 'mozilla-certvalidations', 'mozilla-certvalidations-by-root', 'mozilla-certvalidations-by-owner', 'mozilla-certvalidations-by-version', 'mozilla-disclosures', 'mozilla-onecrl', 'microsoft-disclosures', 'redacted-precertificates') THEN t_type := lower(t_outputType); @@ -385,7 +393,7 @@ BEGIN END IF; -- Generate page header. - t_output := ''; + t_output := coalesce(t_output, ''); IF t_outputType = 'html' THEN t_output := '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> @@ -778,6 +786,25 @@ BEGIN + ''&parenturl='' + encodeURIComponent(window.location.href); </SCRIPT>'; + ELSIF t_type = 'logs.json' THEN + t_temp := coalesce(get_parameter('include', paramNames, paramValues), 'active'); + t_output := t_output || '{' || chr(10) || ' "logs": [' || chr(10); + FOR l_record IN ( + SELECT ctl.NAME, ctl.PUBLIC_KEY, ctl.URL, ctl.MMD_IN_SECONDS + FROM ct_log ctl + WHERE ctl.IS_ACTIVE = CASE WHEN t_temp = 'all' THEN ctl.IS_ACTIVE ELSE 't' END + ORDER BY ctl.NAME + ) LOOP + t_output := t_output || ' {' || chr(10) + || ' "description": "' || l_record.NAME || '",' || chr(10) + || ' "log_id": "' || encode(digest(l_record.PUBLIC_KEY, 'sha256'), 'base64') || '",' || chr(10) + || ' "key": "' || replace(encode(l_record.PUBLIC_KEY, 'base64'), chr(10), '') || '",' || chr(10) + || ' "url": "' || l_record.URL || '",' || chr(10) + || ' "maximum_merge_delay": ' || coalesce(l_record.MMD_IN_SECONDS::text, '') || chr(10) + || ' },' || chr(10); + END LOOP; + t_output := rtrim(t_output, ',' || chr(10)) || chr(10) || ' ]' || chr(10) || '}'; + ELSIF t_type = 'monitored-logs' THEN t_output := t_output || ' <SPAN class="whiteongrey">Monitored Logs</SPAN> |