Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

fix(api): before sunset #542

Merged
merged 4 commits into from
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions httpobs/website/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@
from httpobs.conf import API_ALLOW_VERBOSE_STATS_FROM_PUBLIC, API_COOLDOWN, DEVELOPMENT_MODE
from httpobs.scanner import scan
from httpobs.scanner.grader import GRADES, get_score_description
from httpobs.website import (
add_response_headers,
add_sunset_headers,
check_for_deprecation_override_header,
sanitized_api_response,
)
from httpobs.website import add_response_headers, add_sunset_headers, sanitized_api_response
from httpobs.website.utils import valid_hostname

api = Blueprint('api', __name__)
Expand All @@ -26,8 +21,8 @@

@api.route('/api/v1/analyze', methods=['GET', 'OPTIONS', 'POST'])
@add_sunset_headers()
@check_for_deprecation_override_header
@add_response_headers(cors=True)
# @check_for_deprecation_override_header
@sanitized_api_response
def api_post_scan_hostname():
# TODO: Allow people to accidentally use https://mozilla.org and convert to mozilla.org
Expand Down Expand Up @@ -127,8 +122,8 @@ def api_post_scan_hostname():
# TODO: Deprecate this and replace with __stats__ once website is updated
@api.route('/api/v1/getGradeDistribution', methods=['GET', 'OPTIONS'])
@add_sunset_headers()
@check_for_deprecation_override_header
@add_response_headers(cors=True)
# @check_for_deprecation_override_header
def api_get_grade_totals():
totals = database.select_star_from('grade_distribution')

Expand All @@ -140,8 +135,8 @@ def api_get_grade_totals():

@api.route('/api/v1/getHostHistory', methods=['GET', 'OPTIONS'])
@add_sunset_headers()
@check_for_deprecation_override_header
@add_response_headers(cors=True)
# @check_for_deprecation_override_header
def api_get_host_history():
# Get the hostname
hostname = request.args.get('host', '').lower()
Expand Down Expand Up @@ -175,8 +170,8 @@ def api_get_host_history():

@api.route('/api/v1/getRecentScans', methods=['GET', 'OPTIONS'])
@add_sunset_headers()
@check_for_deprecation_override_header
@add_response_headers(cors=True)
# @check_for_deprecation_override_header
def api_get_recent_scans():
try:
# Get the min and max scores, if they're there
Expand All @@ -198,8 +193,8 @@ def api_get_recent_scans():
# TODO: Deprecate
@api.route('/api/v1/getScannerStates', methods=['GET', 'OPTIONS'])
@add_sunset_headers()
@check_for_deprecation_override_header
@add_response_headers(cors=True)
# @check_for_deprecation_override_header
def api_get_scanner_states():
stats = database.select_scan_scanner_statistics(verbose=False)

Expand All @@ -208,8 +203,8 @@ def api_get_scanner_states():

@api.route('/api/v1/__stats__', methods=['GET', 'OPTIONS'])
@add_sunset_headers()
@check_for_deprecation_override_header
@add_response_headers(cors=True)
# @check_for_deprecation_override_header
def api_get_scanner_stats():
pretty = True if request.args.get('pretty', '').lower() == 'true' else False
verbose = False
Expand Down Expand Up @@ -277,8 +272,8 @@ def api_get_scanner_stats():

@api.route('/api/v1/getScanResults', methods=['GET', 'OPTIONS'])
@add_sunset_headers()
@check_for_deprecation_override_header
@add_response_headers(cors=True)
# @check_for_deprecation_override_header
@sanitized_api_response
def api_get_scan_results():
scan_id = request.args.get('scan')
Expand Down Expand Up @@ -308,8 +303,8 @@ def api_get_scan_results():

@api.route('/contribute.json', methods=['GET'])
@add_sunset_headers()
@check_for_deprecation_override_header
@add_response_headers()
# @check_for_deprecation_override_header
def contribute_json():
__dirname = os.path.abspath(os.path.dirname(__file__))
__filename = os.path.join(__dirname, '..', 'docs', 'contribute.json')
Expand Down
Loading