コード例 #1
0
def cmdline():
    parser = argparse.ArgumentParser(description=DESCRIPTION)
    parser.add_argument('-v', '--verbose', action='store_true')
    parser.add_argument('-w', '--windows', action='store_true')
    parser.add_argument('--version', action='store_true')
    args = parser.parse_args()

    if args.version:
        version_info = get_version_info()
        for key in sorted(version_info):
            print('{}: {}'.format(key, version_info[key]))
        return

    crash_processor = CrashProcessor(verbose=args.verbose,
                                     windows=args.windows)
    try:
        payload = json.loads(sys.stdin.read())
    except ValueError:
        if args.verbose:
            print('fx-crash-sig: Failed: Invalid input format')
        return

    try:
        signature = crash_processor.get_signature(payload)
        if signature is not None:
            print(json.dumps(signature))
    except Exception as e:
        if args.verbose:
            print('fx-crash-sig: Failed: {}'.format(e.message))
コード例 #2
0
def cmdline():
    parser = argparse.ArgumentParser(description=DESCRIPTION)
    parser.add_argument("-v", "--verbose", action="store_true")
    parser.add_argument("-w", "--windows", action="store_true")
    parser.add_argument("--version", action="store_true")
    args = parser.parse_args()

    if args.version:
        version_info = get_version_info()
        for key in sorted(version_info):
            print("{}: {}".format(key, version_info[key]))
        return

    crash_processor = CrashProcessor(verbose=args.verbose, windows=args.windows)

    if sys.stdin.isatty():
        print("fx-crash-sig: Failed: pass crash trace using stdin", file=sys.stderr)
        sys.exit(1)

    try:
        payload = json.loads(sys.stdin.read())
    except ValueError:
        print("fx-crash-sig: Failed: Invalid input format", file=sys.stderr)
        sys.exit(1)

    try:
        siggen_result = crash_processor.get_signature(payload)
    except Exception as exc:
        print(f"fx-crash-sig: Failed with exception: {exc}", file=sys.stderr)
        sys.exit(1)

    if siggen_result is not None:
        data = {
            "signature": siggen_result.signature,
            "notes": siggen_result.notes,
            "extra": siggen_result.extra,
        }
        print(json.dumps(data, indent=2))
コード例 #3
0
ファイル: bigquery-etl.py プロジェクト: mozilla/fx-crash-sig
FROM
  `moz-fx-data-shared-prod`.telemetry.crash
WHERE
  normalized_channel="nightly"
  AND DATE(submission_timestamp)="{date}"
  AND application.build_id > FORMAT_DATE("%Y%m%d", DATE_SUB(DATE "{date}", INTERVAL 1 WEEK))
  AND payload IS NOT NULL
  AND payload.stack_traces IS NOT NULL
  AND payload.stack_traces.crash_info IS NOT NULL
"""

if len(sys.argv) != 2:
    print("USAGE: %s <date in YYYY-MM-DD format>" % sys.argv[0])
    sys.exit(1)

proc = CrashProcessor(verbose=True, windows=True)

client = bigquery.Client()
query_job = client.query(QUERY_TEMPLATE.format(date=sys.argv[1]))
result = query_job.result()

CHUNK_SIZE = 10
chunk_count = math.ceil(result.total_rows / CHUNK_SIZE)
print(f"Rows: {result.total_rows}, Chunks: {chunk_count}", file=sys.stderr)


def get_sigs(chunk):
    (doc_ids, payloads) = chunk
    sigs = proc.get_signatures_multi(doc_ids, payloads)
    return (doc_ids, sigs)
コード例 #4
0
# Using https://sql.telemetry.mozilla.org/queries/78742/source
# you can get an API key url https://sql.telemetry.mozilla.org/api/queries/78742/results.json?api_key=[key]
# for a results.json. Download that and then run this script.
import sys
import json
with open(sys.argv[1]) as f:
    dataset = json.load(f)
props = []
#for r in dataset["query_result"]["data"]["rows"]:
#j = json.loads(r["additional_properties"])
#j["payload"]["metadata"] = json.loads(r["metadata"])
#props.append(j)
#print(props)
from fx_crash_sig.crash_processor import CrashProcessor

proc = CrashProcessor()


def symbolicate(ping):
    try:
        return proc.symbolicate(ping)
    except TypeError:
        return None


def sig_of_sym(payload):
    if payload is None:
        return ""
    try:
        return proc.get_signature_from_symbolicated(payload).signature
    except TypeError:
コード例 #5
0
import ujson as json

from fx_crash_sig import sample_traces
from fx_crash_sig.crash_processor import CrashProcessor


def wrap_in_payload(crash_data):
    return {
        'metadata': {},
        'stackTraces': crash_data
    }


if __name__ == '__main__':
    crash_processor = CrashProcessor(verbose=True)

    trace_dict = wrap_in_payload(json.loads(sample_traces.string_trace2))

    symbolicated = crash_processor.symbolicate(trace_dict)
    print(symbolicated)

    if symbolicated is not None:
        result = crash_processor.get_signature_from_symbolicated(symbolicated)
        print(result.signature)

    results = [crash_processor.get_signature(wrap_in_payload(crash))
               for crash in [
                   sample_traces.trace1,
                   sample_traces.trace2,
               ]]