Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 6 additions & 8 deletions src/appengine/handlers/cron/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

from base import utils
from config import local_config
from handlers import base_handler
from libs import handler
from handlers import base_handler_flask
from libs import handler_flask
from metrics import logs

# CrashStatistic is excluded because the number of records is too high and
Expand All @@ -38,17 +38,17 @@ def _datastore_client():
return googleapiclient.discovery.build('datastore', 'v1')


class Handler(base_handler.Handler):
class Handler(base_handler_flask.Handler):
"""Handler for triggering the backup URL."""

@handler.check_cron()
@handler_flask.cron()
def get(self):
"""Handle a cron job."""
backup_bucket = local_config.Config(
local_config.PROJECT_PATH).get('backup.bucket')
if not backup_bucket:
logs.log('No backup bucket is set, skipping.')
return
return 'OK'

kinds = [
kind for kind in ndb.Model._kind_map # pylint: disable=protected-access
Expand Down Expand Up @@ -80,6 +80,4 @@ def get(self):
status_code = e.resp.status
logs.log_error(message, error=str(e))

self.response.headers['Content-Type'] = 'text/plain'
self.response.out.write(message)
self.response.set_status(status_code)
return (message, status_code, {'Content-Type': 'text/plain'})
8 changes: 4 additions & 4 deletions src/appengine/handlers/cron/batch_fuzzer_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"""A cron handler that batches FuzzerJobs."""

from datastore import data_types
from handlers import base_handler
from libs import handler
from handlers import base_handler_flask
from libs import handler_flask

from google.cloud import ndb

Expand Down Expand Up @@ -56,10 +56,10 @@ def batch_fuzzer_jobs():
ndb.delete_multi(batches_to_remove)


class Handler(base_handler.Handler):
class Handler(base_handler_flask.Handler):
"""Handler for building data_types.CrashsStats2."""

@handler.check_cron()
@handler_flask.cron()
def get(self):
"""Process a GET request from a cronjob."""
batch_fuzzer_jobs()
13 changes: 5 additions & 8 deletions src/appengine/handlers/cron/build_crash_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
from base import utils
from datastore import data_types
from google_cloud_utils import big_query
from handlers import base_handler
from libs import handler
from handlers import base_handler_flask
from libs import handler_flask
from metrics import crash_stats

# After insertion, it takes a few seconds for a record to show up.
Expand Down Expand Up @@ -174,14 +174,11 @@ def build_if_needed():
logging.info("Skip building crash stats because it's too early.")


class Handler(base_handler.Handler):
class Handler(base_handler_flask.Handler):
"""Handler for building data_types.CrashsStats2."""

@handler.check_cron()
@handler_flask.cron()
def get(self):
"""Process a GET request from a cronjob."""
end_hour = build_if_needed()

self.response.headers['Content-Type'] = 'text/plain'
self.response.out.write('OK (end_hour=%s)' % end_hour)
self.response.set_status(200)
return 'OK (end_hour=%s)' % end_hour
8 changes: 4 additions & 4 deletions src/appengine/handlers/cron/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
from datastore import data_types
from datastore import ndb_utils
from fuzzing import leak_blacklist
from handlers import base_handler
from libs import handler
from handlers import base_handler_flask
from libs import handler_flask
from libs import mail
from libs.issue_management import issue_filer
from libs.issue_management import issue_tracker_policy
Expand Down Expand Up @@ -1239,10 +1239,10 @@ def cleanup_unused_heartbeats():
ndb_utils.delete_multi(unused_heartbeats)


class Handler(base_handler.Handler):
class Handler(base_handler_flask.Handler):
"""Cleanup."""

@handler.check_cron()
@handler_flask.cron()
def get(self):
cleanup_testcases_and_issues()
cleanup_reports_metadata()
Expand Down
8 changes: 4 additions & 4 deletions src/appengine/handlers/cron/corpus_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
from datastore import ndb_utils
from fuzzing import corpus_manager
from google_cloud_utils import storage
from handlers import base_handler
from libs import handler
from handlers import base_handler_flask
from libs import handler_flask
from metrics import logs


Expand Down Expand Up @@ -74,10 +74,10 @@ def _make_corpus_backup_public(target, corpus_fuzzer_name_override,
logs.log('Corpus backup %s is now marked public.' % corpus_backup_url)


class MakePublicHandler(base_handler.Handler):
class MakePublicHandler(base_handler_flask.Handler):
"""Makes corpuses older than 90 days public."""

@handler.check_cron()
@handler_flask.cron()
def get(self):
"""Handle a GET request."""
jobs = ndb_utils.get_all_from_model(data_types.Job)
Expand Down
8 changes: 4 additions & 4 deletions src/appengine/handlers/cron/fuzz_strategy_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
from datastore import ndb_utils
from fuzzing import strategy
from google_cloud_utils import big_query
from handlers import base_handler
from libs import handler
from handlers import base_handler_flask
from libs import handler_flask
from metrics import logs

# After experimentation with high, low, and medium temperature parameters, we
Expand Down Expand Up @@ -205,13 +205,13 @@ def _query_and_upload_strategy_probabilities(engine):
engine.name))


class Handler(base_handler.Handler):
class Handler(base_handler_flask.Handler):
"""Cron job handler for fuzz strategy selection.

Handler to periodically update fuzz strategy bandit probabilities
based on a performance metric (currently based on new_edges)."""

@handler.check_cron()
@handler_flask.cron()
def get(self):
"""Process all fuzz targets and update FuzzStrategy weights."""
for engine in ENGINE_LIST:
Expand Down
8 changes: 4 additions & 4 deletions src/appengine/handlers/cron/fuzzer_and_job_weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
from datastore import data_types
from datastore import ndb_utils
from google_cloud_utils import big_query
from handlers import base_handler
from libs import handler
from handlers import base_handler_flask
from libs import handler_flask
from metrics import fuzzer_stats
from metrics import logs
from system import environment
Expand Down Expand Up @@ -386,10 +386,10 @@ def update_job_weights():
update_job_weight(job.name, multiplier)


class Handler(base_handler.Handler):
class Handler(base_handler_flask.Handler):
"""Handler to periodically update fuzz target weights based on performance."""

@handler.check_cron()
@handler_flask.cron()
def get(self):
"""Process all fuzz targets and update FuzzTargetJob weights."""
client = big_query.Client()
Expand Down
8 changes: 4 additions & 4 deletions src/appengine/handlers/cron/fuzzer_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
from datastore import data_types
from datastore import ndb_utils
from google_cloud_utils import storage
from handlers import base_handler
from libs import handler
from handlers import base_handler_flask
from libs import handler_flask
from metrics import logs


Expand Down Expand Up @@ -134,10 +134,10 @@ def collect_fuzzer_coverage(bucket):
_process_project(project, bucket)


class Handler(base_handler.Handler):
class Handler(base_handler_flask.Handler):
"""Collects the latest code coverage stats and links to reports."""

@handler.check_cron()
@handler_flask.cron()
def get(self):
"""Handle a GET request."""
# The task is supposed to be super reliable and never fail. If anything goes
Expand Down
8 changes: 4 additions & 4 deletions src/appengine/handlers/cron/load_bigquery_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
from base import utils
from datastore import data_types
from google_cloud_utils import big_query
from handlers import base_handler
from libs import handler
from handlers import base_handler_flask
from libs import handler_flask
from metrics import fuzzer_stats
from metrics import fuzzer_stats_schema
from metrics import logs
Expand All @@ -36,7 +36,7 @@
RETRY_SLEEP_TIME = 5


class Handler(base_handler.Handler):
class Handler(base_handler_flask.Handler):
"""Cron handler for loading bigquery stats."""

def _utc_now(self):
Expand Down Expand Up @@ -150,7 +150,7 @@ def _load_data(self, bigquery, fuzzer):
# See https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/query.
logs.log('Response from BigQuery: %s' % response)

@handler.check_cron()
@handler_flask.cron()
def get(self):
"""Load bigquery stats from GCS."""
if not big_query.get_bucket():
Expand Down
8 changes: 4 additions & 4 deletions src/appengine/handlers/cron/manage_vms.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
from datastore import data_types
from datastore import ndb_utils
from google_cloud_utils import compute_engine_projects
from handlers import base_handler
from handlers import base_handler_flask
from handlers.cron.helpers import bot_manager
from libs import handler
from libs import handler_flask

PROJECT_MIN_CPUS = 1

Expand Down Expand Up @@ -698,10 +698,10 @@ def assign_hosts_to_workers(self):
self.cleanup_old_assignments(all_host_names)


class Handler(base_handler.Handler):
class Handler(base_handler_flask.Handler):
"""CPU distributor for OSS-Fuzz projects."""

@handler.check_cron()
@handler_flask.cron()
def get(self):
"""Handle a get request."""
if utils.is_oss_fuzz():
Expand Down
8 changes: 4 additions & 4 deletions src/appengine/handlers/cron/ml_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
from base import utils
from datastore import data_types
from datastore import fuzz_target_utils
from handlers import base_handler
from libs import handler
from handlers import base_handler_flask
from libs import handler_flask


class Handler(base_handler.Handler):
class Handler(base_handler_flask.Handler):
"""Schedule ML train tasks."""

@handler.check_cron()
@handler_flask.cron()
def get(self):
"""Handle a GET request."""
for job in data_types.Job.query():
Expand Down
8 changes: 4 additions & 4 deletions src/appengine/handlers/cron/oss_fuzz_apply_ccs.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
from base import memoize
from datastore import data_types
from datastore import ndb_utils
from handlers import base_handler
from libs import handler
from handlers import base_handler_flask
from libs import handler_flask
from libs.issue_management import issue_filer
from libs.issue_management import issue_tracker_policy
from libs.issue_management import issue_tracker_utils
Expand All @@ -35,10 +35,10 @@ def get_open_testcases_with_bugs():
data_types.Testcase.bug_information, data_types.Testcase.key)


class Handler(base_handler.Handler):
class Handler(base_handler_flask.Handler):
"""Cron handler for adding new CC's to oss-fuzz bugs.."""

@handler.check_cron()
@handler_flask.cron()
def get(self):
"""Handle a cron job."""

Expand Down
8 changes: 4 additions & 4 deletions src/appengine/handlers/cron/oss_fuzz_build_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

from base import utils
from datastore import data_types
from handlers import base_handler
from libs import handler
from handlers import base_handler_flask
from libs import handler_flask
from libs import helpers
from libs.issue_management import issue_tracker_utils
from metrics import logs
Expand Down Expand Up @@ -181,7 +181,7 @@ def send_reminder(issue_tracker, issue_id, build_id):
issue.save(new_comment=comment, notify=True)


class Handler(base_handler.Handler):
class Handler(base_handler_flask.Handler):
"""Build status checker."""

def _close_fixed_builds(self, projects, build_type):
Expand Down Expand Up @@ -285,7 +285,7 @@ def _check_last_get_build_time(self, projects, build_type):
logs.log_error('%s has not been built in %s config for %d days.' %
(project_name, build_type, time_since_last_build.days))

@handler.check_cron()
@handler_flask.cron()
def get(self):
"""Handles a get request."""
for build_type, status_url in BUILD_STATUS_MAPPINGS:
Expand Down
8 changes: 4 additions & 4 deletions src/appengine/handlers/cron/oss_fuzz_generate_certs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

from base import untrusted
from datastore import data_types
from handlers import base_handler
from libs import handler
from handlers import base_handler_flask
from libs import handler_flask
from metrics import logs


Expand Down Expand Up @@ -46,10 +46,10 @@ def generate_cert(project_name):
return cert_contents, key_contents


class Handler(base_handler.Handler):
class Handler(base_handler_flask.Handler):
"""Generate OSS-Fuzz certs."""

@handler.check_cron()
@handler_flask.cron()
def get(self):
"""Handles a get request."""
for project in data_types.OssFuzzProject.query():
Expand Down
8 changes: 4 additions & 4 deletions src/appengine/handlers/cron/predator_pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
from config import db_config
from datastore import data_handler
from google_cloud_utils import pubsub
from handlers import base_handler
from libs import handler
from handlers import base_handler_flask
from libs import handler_flask
from metrics import logs


class Handler(base_handler.Handler):
class Handler(base_handler_flask.Handler):
"""Handler to periodically gather new results from Predator requests."""

@handler.check_cron()
@handler_flask.cron()
def get(self):
"""Process a GET request."""
subscription = db_config.get_value('predator_result_topic')
Expand Down
Loading