Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Typos Across the Project and Rename defintions.py to definitions.py #847

Merged
merged 2 commits into from
Dec 6, 2024
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
6 changes: 3 additions & 3 deletions src/ostorlab/agent/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import List, Optional, Dict, Any

from ostorlab.agent.schema import loader
from ostorlab.utils import defintions
from ostorlab.utils import definitions

Check warning on line 8 in src/ostorlab/agent/definitions.py

View check run for this annotation

Codecov / codecov/patch

src/ostorlab/agent/definitions.py#L8

Added line #L8 was not covered by tests


@dataclasses.dataclass
Expand All @@ -20,7 +20,7 @@
mounts: List[str] = dataclasses.field(default_factory=list)
restart_policy: str = ""
mem_limit: int = None
open_ports: List[defintions.PortMapping] = dataclasses.field(default_factory=list)
open_ports: List[definitions.PortMapping] = dataclasses.field(default_factory=list)

Check warning on line 23 in src/ostorlab/agent/definitions.py

View check run for this annotation

Codecov / codecov/patch

src/ostorlab/agent/definitions.py#L23

Added line #L23 was not covered by tests
restrictions: List[str] = dataclasses.field(default_factory=list)
version: Optional[str] = None
description: Optional[str] = None
Expand Down Expand Up @@ -55,7 +55,7 @@
restart_policy=definition.get("restart_policy", ""),
mem_limit=definition.get("mem_limit"),
open_ports=[
defintions.PortMapping(
definitions.PortMapping(
source_port=p.get("src_port"),
destination_port=p.get("dest_port"),
)
Expand Down
2 changes: 1 addition & 1 deletion src/ostorlab/agent/mixins/agent_healthcheck_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def run(self) -> None:
self._server.serve_forever()

def start(self) -> None:
"""Start thread in deamon mode.
"""Start thread in daemon mode.

Returns:
None
Expand Down
4 changes: 2 additions & 2 deletions src/ostorlab/agent/mixins/agent_mq_mixin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""MQ Mixin.

Defintion of the main methods to publish and consume MQ messages by the agents.
Definition of the main methods to publish and consume MQ messages by the agents.
"""

import asyncio
Expand Down Expand Up @@ -104,7 +104,7 @@ async def _declare_mq_queue(
delete_queue_first: bool = False,
) -> None:
"""Declare the MQ queue on a given channel.
The queue is durable, re-declaring the queue will return the same queue
The queue is durable, redeclaring the queue will return the same queue
Args:
channel: the MQ channel to use for the queues
delete_queue_first: Used for testing purposes. To delete pending queues first.
Expand Down
2 changes: 1 addition & 1 deletion src/ostorlab/agent/mixins/agent_open_telemetry_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def process_message(self, selector: str, message: bytes) -> None:
def emit(
self, selector: str, data: Dict[str, Any], message_id: Optional[str] = None
) -> None:
"""Overriden emit method of the agent to add OpenTelemetry traces.
"""Overridden emit method of the agent to add OpenTelemetry traces.
Sends a message to all listening agents on the specified selector.

Args:
Expand Down
2 changes: 1 addition & 1 deletion src/ostorlab/agent/mixins/agent_persist_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def hash_add(
mapping: Dict[Union[bytes, str], Union[bytes, str]],
) -> bool:
"""Set mapping within hash hash_name. If hash_name does not exist a new hash is created.
If key exists, value is overriden.
If key exists, value is overridden.

Args:
hash_name: Name of the hash.
Expand Down
4 changes: 2 additions & 2 deletions src/ostorlab/apis/add_scanner_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import json

from ostorlab.apis import request
from ostorlab.utils import defintions
from ostorlab.utils import definitions

Check warning on line 7 in src/ostorlab/apis/add_scanner_state.py

View check run for this annotation

Codecov / codecov/patch

src/ostorlab/apis/add_scanner_state.py#L7

Added line #L7 was not covered by tests


class AddScannerStateAPIRequest(request.APIRequest):
"""Report the scanner state."""

def __init__(self, state: defintions.ScannerState):
def __init__(self, state: definitions.ScannerState):

Check warning on line 13 in src/ostorlab/apis/add_scanner_state.py

View check run for this annotation

Codecov / codecov/patch

src/ostorlab/apis/add_scanner_state.py#L13

Added line #L13 was not covered by tests
"""Sets the state values.

Args:
Expand Down
2 changes: 1 addition & 1 deletion src/ostorlab/apis/test_credentials_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def to_variables(self) -> Dict[str, Any]:

@dataclasses.dataclass
class TestCredentialLogin(TestCredential):
"""Loging password test credentials with optional role and url fields."""
"""Login password test credentials with optional role and url fields."""

login: str
password: str
Expand Down
2 changes: 1 addition & 1 deletion src/ostorlab/apis/vulnz_describe.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Lists full details of a single vulnerability or all the vulnerabilities for a specif scan."""
"""Lists full details of a single vulnerability or all the vulnerabilities for a specific scan."""

import json
from typing import Dict, Optional
Expand Down
2 changes: 1 addition & 1 deletion src/ostorlab/cli/agent/agent.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Agent module that handles building, searching, installing, bootstraping and running an agent."""
"""Agent module that handles building, searching, installing, bootstrapping and running an agent."""

from ostorlab.cli.rootcli import rootcli

Expand Down
2 changes: 1 addition & 1 deletion src/ostorlab/cli/agent/install/install_progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


class AgentInstallProgress(progress.Progress):
"""Class reponsible for displaying the progress of the agent installation."""
"""Class responsible for displaying the progress of the agent installation."""

def __init__(self):
super().__init__(
Expand Down
2 changes: 1 addition & 1 deletion src/ostorlab/cli/agent/search/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def search_agents(search: str) -> Dict:
List of agent matching the search.

Raises:
click Exit exception with satus code 2 when API response is invalid.
click Exit exception with status code 2 when API response is invalid.
"""
config_manager = configuration_manager.ConfigurationManager()

Expand Down
2 changes: 1 addition & 1 deletion src/ostorlab/cli/ci_scan/run/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
ci_logger = CI_LOGGER.get(log_flavor)()

if len(test_credentials_login) != len(test_credentials_password):
ci_logger.error("Loging and password credentials are not matching count.")
ci_logger.error("Login and password credentials are not matching count.")

Check warning on line 162 in src/ostorlab/cli/ci_scan/run/run.py

View check run for this annotation

Codecov / codecov/patch

src/ostorlab/cli/ci_scan/run/run.py#L162

Added line #L162 was not covered by tests
raise click.exceptions.Exit(2)

if len(test_credentials_name) != len(test_credentials_value):
Expand Down
2 changes: 1 addition & 1 deletion src/ostorlab/cli/docker_requirements_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
WAIT_TIME = 2

# The architecture is checked with a return value that's based on the kernel implementation of the uname(2)
# system call. So it might be necesarry to handle the same arch with various strings e.g. linux returns x86_64
# system call. So it might be necessary to handle the same arch with various strings e.g. linux returns x86_64
# or AMD64 on windows.


Expand Down
2 changes: 1 addition & 1 deletion src/ostorlab/cli/scan/run/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from ostorlab.cli import agent_fetcher
from ostorlab.runtimes import definitions
from ostorlab.runtimes import runtime
from ostorlab.utils import defintions as utils_definitions
from ostorlab.utils import definitions as utils_definitions

Check warning on line 24 in src/ostorlab/cli/scan/run/run.py

View check run for this annotation

Codecov / codecov/patch

src/ostorlab/cli/scan/run/run.py#L24

Added line #L24 was not covered by tests


console = cli_console.Console()
Expand Down
16 changes: 8 additions & 8 deletions src/ostorlab/runtimes/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from ostorlab.agent.schema import loader
from ostorlab.cli import agent_fetcher
from ostorlab.runtimes.proto import agent_instance_settings_pb2
from ostorlab.utils import defintions
from ostorlab.utils import definitions

Check warning on line 15 in src/ostorlab/runtimes/definitions.py

View check run for this annotation

Codecov / codecov/patch

src/ostorlab/runtimes/definitions.py#L15

Added line #L15 was not covered by tests
from ostorlab.assets import android_apk as android_apk_asset
from ostorlab.assets import android_aab as android_aab_asset
from ostorlab.assets import android_store as android_store_asset
Expand Down Expand Up @@ -49,12 +49,12 @@
bus_exchange_topic: Optional[str] = ""
bus_management_url: Optional[str] = ""
bus_vhost: Optional[str] = ""
args: List[defintions.Arg] = dataclasses.field(default_factory=list)
args: List[definitions.Arg] = dataclasses.field(default_factory=list)

Check warning on line 52 in src/ostorlab/runtimes/definitions.py

View check run for this annotation

Codecov / codecov/patch

src/ostorlab/runtimes/definitions.py#L52

Added line #L52 was not covered by tests
constraints: Optional[List[str]] = dataclasses.field(default_factory=list)
mounts: Optional[List[str]] = dataclasses.field(default_factory=list)
restart_policy: str = ""
mem_limit: Optional[int] = None
open_ports: List[defintions.PortMapping] = dataclasses.field(default_factory=list)
open_ports: List[definitions.PortMapping] = dataclasses.field(default_factory=list)

Check warning on line 57 in src/ostorlab/runtimes/definitions.py

View check run for this annotation

Codecov / codecov/patch

src/ostorlab/runtimes/definitions.py#L57

Added line #L57 was not covered by tests
replicas: int = 1
healthcheck_host: str = "0.0.0.0"
healthcheck_port: int = 5000
Expand Down Expand Up @@ -89,15 +89,15 @@
bus_management_url=instance.bus_management_url,
bus_vhost=instance.bus_vhost,
args=[
defintions.Arg(name=a.name, type=a.type, value=a.value)
definitions.Arg(name=a.name, type=a.type, value=a.value)
for a in instance.args
],
constraints=instance.constraints,
mounts=instance.mounts,
restart_policy=instance.restart_policy,
mem_limit=instance.mem_limit,
open_ports=[
defintions.PortMapping(
definitions.PortMapping(
source_port=p.source_port, destination_port=p.destination_port
)
for p in instance.open_ports
Expand Down Expand Up @@ -205,7 +205,7 @@
key=agent.get("key"),
version=agent.get("version"),
args=[
defintions.Arg(
definitions.Arg(
name=a.get("name"),
description=a.get("description"),
type=a.get("type"),
Expand All @@ -218,7 +218,7 @@
restart_policy=agent.get("restart_policy", ""),
mem_limit=agent.get("mem_limit"),
open_ports=[
defintions.PortMapping(
definitions.PortMapping(
source_port=p.get("src_port"),
destination_port=p.get("dest_port"),
)
Expand Down Expand Up @@ -254,7 +254,7 @@
replicas = _process_agent_replicas(agent.replicas)
agent_args = []
for arg in agent.args:
agent_arg = defintions.Arg.build(
agent_arg = definitions.Arg.build(
name=arg.name,
type=arg.type,
value=arg.value,
Expand Down
2 changes: 1 addition & 1 deletion src/ostorlab/runtimes/lite_local/agent_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def create_definition_config(self) -> docker.types.ConfigReference:
"""Create a docker configuration of the agent definition.

Returns:
docker configuration reference of the agent defintion configuration.
docker configuration reference of the agent definition configuration.
"""
agent_definition = self._docker_client.images.get(
self.agent.container_image
Expand Down
2 changes: 1 addition & 1 deletion src/ostorlab/runtimes/local/agent_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def create_definition_config(self) -> docker.types.ConfigReference:
"""Create a docker configuration of the agent definition.

Returns:
docker configuration reference of the agent defintion configuration.
docker configuration reference of the agent definition configuration.
"""
agent_definition = self._docker_client.images.get(
self.agent.container_image
Expand Down
2 changes: 1 addition & 1 deletion src/ostorlab/runtimes/local/log_streamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self):
def stream(self, service: docker.models.services.Service) -> None:
"""Stream logs of a service without blocking.

Implementation spawns a dedicated deamon thread.
Implementation spawns a dedicated daemon thread.

Args:
service: Docker service.
Expand Down
2 changes: 1 addition & 1 deletion src/ostorlab/runtimes/local/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def __init__(self):
self._alembic_cfg = config.Config(str(self._alembic_ini_path))

def __enter__(self) -> orm.Session:
"""Context manager enter method, resposible for migrating the local database and returning a session object."""
"""Context manager enter method, responsible for migrating the local database and returning a session object."""
self._migrate_local_db()
return self._prepare_db_session()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%% advanced.config
%% The consumer timeout is disabled due to some agents like nmap who takes too much time to finish their task and aknowledge the message.
%% The consumer timeout is disabled due to some agents like nmap who takes too much time to finish their task and acknowledge the message.
[
{rabbit, [
{consumer_timeout, undefined}
Expand Down
2 changes: 1 addition & 1 deletion src/ostorlab/serve_app/oxo.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from ostorlab.serve_app import common, export_utils
from ostorlab.serve_app import import_utils
from ostorlab.serve_app import types
from ostorlab.utils import defintions as utils_definitions
from ostorlab.utils import definitions as utils_definitions

DEFAULT_NUMBER_ELEMENTS = 15

Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions src/ostorlab/utils/scanner_state_reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from ostorlab.apis.runners import authenticated_runner
from ostorlab.apis import add_scanner_state
from ostorlab.utils import defintions
from ostorlab.utils import definitions

Check warning on line 5 in src/ostorlab/utils/scanner_state_reporter.py

View check run for this annotation

Codecov / codecov/patch

src/ostorlab/utils/scanner_state_reporter.py#L5

Added line #L5 was not covered by tests


class ScannerStateReporter:
Expand All @@ -19,12 +19,12 @@
self._hostname = hostname
self._ip = ip

def _capture_state(self) -> defintions.ScannerState:
def _capture_state(self) -> definitions.ScannerState:

Check warning on line 22 in src/ostorlab/utils/scanner_state_reporter.py

View check run for this annotation

Codecov / codecov/patch

src/ostorlab/utils/scanner_state_reporter.py#L22

Added line #L22 was not covered by tests
"""Capture current scanner state."""
try:
import psutil

state = defintions.ScannerState(
state = definitions.ScannerState(
scanner_id=self._scanner_id,
scan_id=self.scan_id,
cpu_load=psutil.cpu_percent(interval=1, percpu=False),
Expand All @@ -35,7 +35,7 @@
ip=self._ip,
)
except ImportError:
state = defintions.ScannerState(
state = definitions.ScannerState(

Check warning on line 38 in src/ostorlab/utils/scanner_state_reporter.py

View check run for this annotation

Codecov / codecov/patch

src/ostorlab/utils/scanner_state_reporter.py#L38

Added line #L38 was not covered by tests
scanner_id=self._scanner_id,
scan_id=self.scan_id,
cpu_load=0,
Expand All @@ -48,7 +48,7 @@

return state

def _report_state(self, state: defintions.ScannerState) -> None:
def _report_state(self, state: definitions.ScannerState) -> None:

Check warning on line 51 in src/ostorlab/utils/scanner_state_reporter.py

View check run for this annotation

Codecov / codecov/patch

src/ostorlab/utils/scanner_state_reporter.py#L51

Added line #L51 was not covered by tests
runner = authenticated_runner.AuthenticatedAPIRunner()
_ = runner.execute(add_scanner_state.AddScannerStateAPIRequest(state=state))

Expand Down
2 changes: 1 addition & 1 deletion tests/agent/agent_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from ostorlab.agent.message import message as agent_message
from ostorlab.runtimes import definitions as runtime_definitions
from ostorlab.testing import agent as agent_testing
from ostorlab.utils import defintions as utils_definitions
from ostorlab.utils import definitions as utils_definitions
from ostorlab.utils import system

logger = logging.getLogger(__name__)
Expand Down
2 changes: 1 addition & 1 deletion tests/agent/definitions_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import io

from ostorlab.agent import definitions
from ostorlab.utils import defintions as utils_defintions
from ostorlab.utils import definitions as utils_defintions


def testAgentDefinitionFromYaml_whenYamlIsValid_returnsValidAgentDefinition():
Expand Down
2 changes: 1 addition & 1 deletion tests/agent/message/serializer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


def testSerializeRequest_withFileFingerprint_returnsCorrectProtobufMessage():
"""Test message proper seralization from a dict object to a protobuf based on the selector."""
"""Test message proper serialization from a dict object to a protobuf based on the selector."""
serialized = serializer.serialize(
"v3.fingerprint.file",
{
Expand Down
2 changes: 1 addition & 1 deletion tests/agent/schema/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def testAgentSpecValidation_whenVersionDoesNotRespectSemanticVersionning_raiseVa
):
"""Unit test to checks the validity of the Agent json-schema.
Case where the Agent definition is invalid.
The version does not respect the semantic versionning : major.minor.release.
The version does not respect the semantic versioning : major.minor.release.
"""

invalid_yaml_data = """
Expand Down
2 changes: 1 addition & 1 deletion tests/cli/agent/search/search_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


def testAgentSearchCLI_WhenAuthenticatedRunner_listAgents(mocker, httpx_mock):
"""Test oxo agent search CLI command with Autenticated API returns list of agents."""
"""Test oxo agent search CLI command with Authenticated API returns list of agents."""
mock.patch("ostorlab.api.runners.authenticated_runner")
mocker.patch(
"ostorlab.configuration_manager.ConfigurationManager.api_key",
Expand Down
10 changes: 5 additions & 5 deletions tests/runtimes/definitions_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


from ostorlab.runtimes import definitions
from ostorlab.utils import defintions as utils_definitions
from ostorlab.utils import definitions as utils_definitions
from ostorlab.scanner.proto.scan._location import startAgentScan_pb2
from ostorlab.scanner.proto.assets import apk_pb2
from ostorlab.assets import android_apk as android_apk_asset
Expand Down Expand Up @@ -374,7 +374,7 @@ def testAssetGroupDefinitionFromYaml_whenYamlIsValid_returnsValidAssetGroupDefin
name: master_scan
assets:
androidStore:
- package_name: "com.ceaser.salad"
- package_name: "com.caesar.salad"
- package_name: "test.this.schema"
androidApkFile:
- path: /tests/files/fake_app.apk
Expand All @@ -383,7 +383,7 @@ def testAssetGroupDefinitionFromYaml_whenYamlIsValid_returnsValidAssetGroupDefin
- path: /tests/files/fake_app.aab
- path: /tests/files/fake_app_2.aab
iosStore:
- bundle_id: "com.ceaser.salad"
- bundle_id: "com.caesar.salad"
- bundle_id: "test.this.schema"
iosFile:
- path: /files/fake_app.ipa
Expand Down Expand Up @@ -417,9 +417,9 @@ def testAssetGroupDefinitionFromYaml_whenYamlIsValid_returnsValidAssetGroupDefin
),
ios_ipa_asset.IOSIpa(content=b"content", path="/files/fake_app.ipa"),
ios_ipa_asset.IOSIpa(content_url="https://cia.sketchy.com/secret_files.ipa"),
android_store_asset.AndroidStore(package_name="com.ceaser.salad"),
android_store_asset.AndroidStore(package_name="com.caesar.salad"),
android_store_asset.AndroidStore(package_name="test.this.schema"),
ios_store_asset.IOSStore(bundle_id="com.ceaser.salad"),
ios_store_asset.IOSStore(bundle_id="com.caesar.salad"),
ios_store_asset.IOSStore(bundle_id="test.this.schema"),
ipv4_asset.IPv4(host="10.21.11.11", mask=30),
ipv4_asset.IPv4(host="0.1.2.1", mask=None),
Expand Down
Loading
Loading