diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index bbf6b4cd3..02cbafa18 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -1,14 +1,13 @@ -name: Bug report -description: File a bug report -labels: ["bug"] +name: Bug Report +description: Report a bug or unexpected behavior +labels: ["bug", "needs triage"] body: - type: dropdown id: package attributes: - label: Installation method + label: Installation Method description: | - Some packages are maintained by the community, rather than by the Sherlock Project. - Knowing which packages are affected helps us diagnose package-specific bugs. + Select the method used to install the software. Knowing the installation method helps diagnose package-specific bugs. options: - Select one - PyPI (via pip) @@ -16,47 +15,83 @@ body: - Docker - Kali repository (via apt) - Built from source - - Other (indicate below) + - Other (please specify below) validations: required: true + + - type: input + id: version + attributes: + label: Software Version + description: | + Specify the version of the software you are using. If you are unsure, please type "Unknown." + placeholder: e.g., v1.2.3 + validations: + required: true + - type: textarea id: description attributes: - label: Description + label: Bug Description description: | - Detailed descriptions that help contributors understand and reproduce your bug are much more likely to lead to a fix. - Please include the following information: - - What you were trying to do + Provide a detailed description of the bug. Clearly describe: + - What you were trying to accomplish - What you expected to happen - - What actually happened + - What actually occurred + - Why you think this is an issue placeholder: | When doing {action}, the expected result should be {expected result}. - When doing {action}, however, the actual result was {actual result}. - This is undesirable because {reason}. + However, the actual result was {actual result}. + This behavior is problematic because {reason}. validations: required: true + - type: textarea id: steps-to-reproduce attributes: - label: Steps to reproduce - description: Write a step by step list that will allow us to reproduce this bug. + label: Steps to Reproduce + description: | + Provide a step-by-step guide that someone else can follow to recreate the issue. Include as much detail as possible. placeholder: | 1. Do something 2. Then do something else + 3. Observe the issue + validations: + required: true + + - type: textarea + id: expected-behavior + attributes: + label: Expected Behavior + description: Describe what you expected to happen if the bug did not occur. + placeholder: Describe the expected output or behavior. validations: required: true + + - type: textarea + id: actual-behavior + attributes: + label: Actual Behavior + description: Describe what actually happened, including any error messages. + placeholder: Describe the actual output or behavior. + validations: + required: true + - type: textarea id: additional-info attributes: - label: Additional information - description: If you have some additional information, please write it here. + label: Additional Information + description: Include any other details you think might be relevant, such as error logs, screenshots, or code snippets. + placeholder: Additional context, error logs, screenshots, etc. validations: required: false + - type: checkboxes id: terms attributes: - label: Code of Conduct - description: By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/sherlock-project/sherlock/blob/master/docs/CODE_OF_CONDUCT.md). + label: Code of Conduct Agreement + description: | + By submitting this issue, you agree to follow our [Code of Conduct](https://github.com/sherlock-project/sherlock/blob/master/docs/CODE_OF_CONDUCT.md). options: - label: I agree to follow this project's Code of Conduct required: true diff --git a/tests/conftest.py b/tests/conftest.py index 51c908146..6f9834124 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,20 +4,52 @@ import pytest from sherlock_project.sites import SitesInformation + +# Fixture to initialize a SitesInformation object @pytest.fixture() def sites_obj(): - sites_obj = SitesInformation(data_file_path=os.path.join(os.path.dirname(__file__), "../sherlock_project/resources/data.json")) - yield sites_obj + """ + Fixture for creating a SitesInformation instance with data loaded from the local JSON file. + """ + data_file = os.path.join(os.path.dirname(__file__), "../sherlock_project/resources/data.json") + if not os.path.exists(data_file): + raise FileNotFoundError(f"Data file not found: {data_file}") + yield SitesInformation(data_file_path=data_file) + +# Fixture to provide site information as a dictionary (session-wide) @pytest.fixture(scope="session") def sites_info(): - sites_obj = SitesInformation(data_file_path=os.path.join(os.path.dirname(__file__), "../sherlock_project/resources/data.json")) + """ + Fixture that provides site information as a dictionary of site names to site details. + """ + data_file = os.path.join(os.path.dirname(__file__), "../sherlock_project/resources/data.json") + if not os.path.exists(data_file): + raise FileNotFoundError(f"Data file not found: {data_file}") + + sites_obj = SitesInformation(data_file_path=data_file) sites_iterable = {site.name: site.information for site in sites_obj} yield sites_iterable + +# Fixture to fetch and load the remote schema file @pytest.fixture(scope="session") def remote_schema(): - schema_url: str = 'https://raw.githubusercontent.com/sherlock-project/sherlock/master/sherlock_project/resources/data.schema.json' - with urllib.request.urlopen(schema_url) as remoteschema: - schemadat = json.load(remoteschema) - yield schemadat + """ + Fixture to fetch and parse the remote JSON schema for site data validation. + """ + schema_url = 'https://raw.githubusercontent.com/sherlock-project/sherlock/master/sherlock_project/resources/data.schema.json' + try: + with urllib.request.urlopen(schema_url) as remoteschema: + schemadat = json.load(remoteschema) + yield schemadat + except urllib.error.URLError as e: + raise ConnectionError(f"Unable to fetch schema from {schema_url}: {e}") + except json.JSONDecodeError as e: + raise ValueError(f"Error decoding JSON from {schema_url}: {e}") + + +# Utility function to check if the data file exists +def validate_data_file(path): + if not os.path.exists(path): + raise FileNotFoundError(f"Data file does not exist: {path}")