-
Notifications
You must be signed in to change notification settings - Fork 592
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
1,505 additions
and
519 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,37 @@ | ||
## Mock configuration file for testing the contrext links API endpoint! | ||
lookupone: | ||
short_name: 'LookupOne' | ||
match_fields: ['hash'] | ||
validation_regex: '/^[0-9a-f]{40}$|^[0-9a-f]{32}$/i' | ||
context_link: 'https://lookupone.local/q=<ATTR_VALUE>' | ||
redirect_warning: TRUE | ||
# Mock configuration file for testing the context links API endpoint! | ||
## Hardcoded Modules | ||
hardcoded_modules: | ||
module_one: | ||
short_name: "ModuleOne" | ||
validation_regex: "/^[0-9a-f]{64}$/i" | ||
match_fields: | ||
- xml | ||
- xml_string | ||
module_two: | ||
short_name: "ModuleTwo" | ||
match_fields: | ||
- url | ||
- uri | ||
- original_url | ||
|
||
lookuptwo: | ||
short_name: 'LookupTwo' | ||
match_fields: ['sha256_hash', 'hash'] | ||
validation_regex: '/^[0-9a-f]{64}$/i' | ||
context_link: 'https://lookuptwo.local/q=<ATTR_VALUE>' | ||
redirect_warning: FALSE | ||
## External Services | ||
linked_services: | ||
lookupone: | ||
short_name: "LookupOne" | ||
match_fields: ["hash"] | ||
validation_regex: "/^[0-9a-f]{40}$|^[0-9a-f]{32}$/i" | ||
context_link: "https://lookupone.local/q=<ATTR_VALUE>" | ||
redirect_warning: TRUE | ||
|
||
lookupthree: | ||
short_name: 'LookupThree' | ||
match_fields: ['url'] | ||
context_link: 'https://lookupthree.local/q=<ATTR_VALUE>' | ||
redirect_warning: TRUE | ||
lookuptwo: | ||
short_name: "LookupTwo" | ||
match_fields: ["sha256_hash", "hash"] | ||
validation_regex: "/^[0-9a-f]{64}$/i" | ||
context_link: "https://lookuptwo.local/q=<ATTR_VALUE>" | ||
redirect_warning: FALSE | ||
|
||
lookupthree: | ||
short_name: "LookupThree" | ||
match_fields: ["url"] | ||
context_link: "https://lookupthree.local/q=<ATTR_VALUE>" | ||
redirect_warning: TRUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"message","timestamp","datetime","timestamp_desc","data_type" | ||
"Checking timestamp conversion","1331698658000000","2012-03-14T04:17:38+00:00","Time Logged","This event has timestamp" | ||
"Checking timestamp conversion","1658689261000000","2022-07-24T19:01:01+0000","Time Logged","This event has timestamp" | ||
"Make sure message is same","1437789661000000","2015-07-25 02:01:01+00:00","Logging","This data_type should stay the same" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Copyright 2023 Google Inc. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""Unfurl API for version 1 of the Timesketch API.""" | ||
|
||
import logging | ||
import unfurl | ||
|
||
from flask import jsonify | ||
from flask import request | ||
from flask import abort | ||
from flask_restful import Resource | ||
from flask_login import login_required | ||
|
||
from timesketch.lib.definitions import HTTP_STATUS_CODE_BAD_REQUEST | ||
from timesketch.lib.definitions import HTTP_STATUS_CODE_INTERNAL_SERVER_ERROR | ||
|
||
logger = logging.getLogger("timesketch.api_unfurl") | ||
|
||
|
||
class UnfurlResource(Resource): | ||
"""Resource to get unfurl information.""" | ||
|
||
@login_required | ||
def post(self): | ||
"""Handles POST request to the resource. | ||
Returns: | ||
JSON object including version info | ||
""" | ||
form = request.json | ||
if not form: | ||
abort( | ||
HTTP_STATUS_CODE_BAD_REQUEST, | ||
"No JSON data provided", | ||
) | ||
|
||
if "url" not in form: | ||
abort( | ||
HTTP_STATUS_CODE_BAD_REQUEST, | ||
"url parameter is required", | ||
) | ||
|
||
url = form.get("url") | ||
|
||
try: | ||
unfurl_result = unfurl.run(url) | ||
except Exception as e: # pylint: disable=broad-except | ||
logger.error("Error unfurling URL: {}".format(e)) | ||
abort( | ||
HTTP_STATUS_CODE_INTERNAL_SERVER_ERROR, | ||
e, | ||
) | ||
|
||
return jsonify(unfurl_result) |
Oops, something went wrong.