Skip to content
Open
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
5 changes: 3 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include README.md LICENSE requirements.txt main.py
include README.md LICENSE requirements.txt
recursive-include src/raven_cycode/library *.yml
recursive-include tests *.py
recursive-include src *
recursive-include src/raven_cycode *
3 changes: 1 addition & 2 deletions deployment/test.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ RUN mkdir -p /raven/tests
WORKDIR /raven
COPY Makefile requirements.txt /raven/
COPY src /raven/src
COPY library /raven/library
COPY tests /raven/tests

# Install any needed packages specified in requirements.txt
RUN pip3 install -r requirements.txt

# Run RAVEN tests
CMD ["make", "test-run"]
CMD ["make", "test-run"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extra line added

4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from src.cmdline import execute
import sys
sys.path.insert(0, "src")
from raven_cycode.cmdline import execute


def main():
Expand Down
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
"Topic :: Security",
],
install_requires=REQUIRMENTS,
packages=find_packages(exclude=("tests", "tests.*")),
entry_points={"console_scripts": ["raven = src.cmdline:execute"]},
packages=find_packages(where="src", exclude=("tests", "tests.*")),
package_dir={"": "src"},
entry_points={"console_scripts": ["raven = raven_cycode.cmdline:execute"]},
include_package_data=True,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this required?
I tried to build the package without this, and it worked. Is there something I am missing?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a safeguard, it looks like it's at True by default but the package wants the data to be included, so I'd suggest to keep it explicit.

)
3 changes: 0 additions & 3 deletions src/__init__.py

This file was deleted.

3 changes: 3 additions & 0 deletions src/raven_cycode/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from raven_cycode.common.ignore_warnings import ignore_warnings

ignore_warnings()
14 changes: 7 additions & 7 deletions src/cmdline.py → src/raven_cycode/cmdline.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import argparse
import src.logger.log as log
from src.common.utils import validate_query_ids
from src.downloader.download import (
import raven_cycode.logger.log as log
from raven_cycode.common.utils import validate_query_ids
from raven_cycode.downloader.download import (
download_all_workflows_and_actions,
download_account_workflows_and_actions,
)
from src.indexer.index import index_downloaded_workflows_and_actions
from src.reporter.report import generate
from src.config.config import (
from raven_cycode.indexer.index import index_downloaded_workflows_and_actions
from raven_cycode.reporter.report import generate
from raven_cycode.config.config import (
load_downloader_config,
load_indexer_config,
load_reporter_config,
)
from src.config.config import (
from raven_cycode.config.config import (
DEBUG_DEFAULT,
MIN_STARS_DEFAULT,
NEO4J_CLEAN_DEFAULT,
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions src/common/utils.py → src/raven_cycode/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import yaml
from py2neo.data import Node

from src.storage.redis_connection import RedisConnection
from src.config.config import Config, QUERY_IDS
import src.logger.log as log
from raven_cycode.storage.redis_connection import RedisConnection
from raven_cycode.config.config import Config, QUERY_IDS
import raven_cycode.logger.log as log
from urllib.parse import urlparse, parse_qs


Expand Down
File renamed without changes.
12 changes: 7 additions & 5 deletions src/config/config.py → src/raven_cycode/config/config.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from src.storage.neo4j_graph import GraphDb
from raven_cycode.storage.neo4j_graph import GraphDb
from pathlib import Path
import raven_cycode

# Default Values
DEBUG_DEFAULT = False
MIN_STARS_DEFAULT = 1000
REDIS_CLEAN_DEFAULT = False
NEO4J_CLEAN_DEFAULT = False
QUERIES_PATH_DEFAULT = "library"
QUERIES_PATH_DEFAULT = Path(raven_cycode.__file__).resolve().parent / "library"
REPORT_RAW_FORMAT = "raw"
REPORT_JSON_FORMAT = "json"
SLACK_REPORTER = "slack"
Expand Down Expand Up @@ -77,7 +79,7 @@ def load_downloader_config(args) -> None:
load_redis_config(args)

if Config.clean_redis:
from src.storage.redis_utils import clean_redis_db
from raven_cycode.storage.redis_utils import clean_redis_db

clean_redis_db()

Expand All @@ -95,8 +97,8 @@ def load_indexer_config(args) -> None:
load_reporter_config(args)

if Config.clean_neo4j or Config.graph.is_graph_empty():
from src.storage.redis_utils import clean_index
from src.storage.neo4j_utils import clean_graph
from raven_cycode.storage.redis_utils import clean_index
from raven_cycode.storage.neo4j_utils import clean_graph

clean_graph()
clean_index()
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
from requests import get

from src.config.config import Config
from src.storage.redis_connection import RedisConnection
from src.downloader.utils import (
from raven_cycode.config.config import Config
from raven_cycode.storage.redis_connection import RedisConnection
from raven_cycode.downloader.utils import (
insert_workflow_or_action_to_redis,
add_ref_pointer_to_redis,
)
from src.downloader.gh_api import (
from raven_cycode.downloader.gh_api import (
get_account_generator,
get_personal_account_generator,
get_repository_generator,
get_repository_workflows,
get_repository_composite_action,
get_repository_reusable_workflow,
)
from src.common.utils import (
from raven_cycode.common.utils import (
find_uses_strings,
convert_workflow_to_unix_path,
get_repo_name_from_path,
convert_raw_github_url_to_github_com_url,
is_url_contains_a_token,
)
from src.workflow_components.dependency import UsesString, UsesStringType
import src.logger.log as log
from raven_cycode.workflow_components.dependency import UsesString, UsesStringType
import raven_cycode.logger.log as log


def download_account_workflows_and_actions() -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from requests import get
from typing import Dict, Any, Optional, Iterator, Optional
from http import HTTPStatus
from src.config.config import Config
import src.logger.log as log
from raven_cycode.config.config import Config
import raven_cycode.logger.log as log

"""
Current rate limiting:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from src.config.config import Config
from src.storage.redis_connection import RedisConnection
from raven_cycode.config.config import Config
from raven_cycode.storage.redis_connection import RedisConnection


def insert_workflow_or_action_to_redis(
Expand Down
File renamed without changes.
12 changes: 6 additions & 6 deletions src/indexer/index.py → src/raven_cycode/indexer/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import yaml
from yaml.constructor import Constructor

from src.storage.redis_connection import RedisConnection
from src.config.config import Config
from src.workflow_components.workflow import Workflow
from src.workflow_components.composite_action import CompositeAction
from raven_cycode.storage.redis_connection import RedisConnection
from raven_cycode.config.config import Config
from raven_cycode.workflow_components.workflow import Workflow
from raven_cycode.workflow_components.composite_action import CompositeAction
from tqdm import tqdm
import src.logger.log as log
from src.common.utils import str_to_bool
import raven_cycode.logger.log as log
from raven_cycode.common.utils import str_to_bool


# A hack to deny PyYAML to convert "on" tags into Python boolean values.
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/logger/log.py → src/raven_cycode/logger/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def info(msg: str) -> None:


def debug(msg: str) -> None:
from src.config.config import Config
from raven_cycode.config.config import Config

if Config.debug:
logger.debug(msg)
Expand All @@ -30,7 +30,7 @@ def warning(msg: str) -> None:


def catch_exit() -> None:
from src.config.config import Config
from raven_cycode.config.config import Config

if Config.github_token:
print("""\n[x] Index results with: raven index""")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from src.config.config import Config, SEVERITY_LEVELS
from raven_cycode.config.config import Config, SEVERITY_LEVELS
import json
from colorama import Fore, Style, init
import textwrap
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from src.config.config import (
from raven_cycode.config.config import (
Config,
REPORT_RAW_FORMAT,
REPORT_JSON_FORMAT,
SLACK_REPORTER,
)
from src.reporter import slack_reporter
from src.logger.log import success_exit
from raven_cycode.reporter import slack_reporter
from raven_cycode.logger.log import success_exit
from os import listdir
from os.path import join
import yaml
import json
from src.queries import Query
from raven_cycode.queries import Query
from typing import List


Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from py2neo.ogm import GraphObject
from py2neo.data import Node
from typing import List, Tuple, Optional
import src.logger.log as log
import raven_cycode.logger.log as log


class GraphDb(object):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from src.config.config import Config
from raven_cycode.config.config import Config


def clean_graph():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from __future__ import annotations

import redis
from src.config.config import Config
import src.logger.log as log
from raven_cycode.config.config import Config
import raven_cycode.logger.log as log


class RedisConnection:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from src.storage.redis_connection import RedisConnection
from src.config.config import Config
from raven_cycode.storage.redis_connection import RedisConnection
from raven_cycode.config.config import Config


def clean_redis_db() -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

from py2neo.ogm import GraphObject, RelatedTo, Property

import src.workflow_components.workflow as workflow
from src.config.config import Config
from src.common.utils import (
import raven_cycode.workflow_components.workflow as workflow
from raven_cycode.config.config import Config
from raven_cycode.common.utils import (
get_dependencies_in_code,
convert_dict_to_list,
raw_str_to_bool,
)
from src.workflow_components.dependency import UsesString, UsesStringType
from raven_cycode.workflow_components.dependency import UsesString, UsesStringType


def get_or_create_composite_action(path: str) -> "CompositeAction":
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
from enum import Enum

from src.common.utils import get_repo_name_from_path
from raven_cycode.common.utils import get_repo_name_from_path


class UsesStringType(Enum):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
from hashlib import md5

from py2neo.ogm import GraphObject, RelatedTo, RelatedFrom, Property
from src.config.config import Config
from src.common.utils import (
from raven_cycode.config.config import Config
from raven_cycode.common.utils import (
get_dependencies_in_code,
get_repo_name_from_path,
convert_dict_to_list,
find_workflow_by_name,
raw_str_to_bool,
)
from src.workflow_components.parsing_utils import (
from raven_cycode.workflow_components.parsing_utils import (
parse_workflow_trigger,
parse_job_machine,
)
from src.workflow_components.dependency import UsesString, UsesStringType
import src.logger.log as log
from raven_cycode.workflow_components.dependency import UsesString, UsesStringType
import raven_cycode.logger.log as log


def get_or_create_workflow(path: str) -> "Workflow":
Expand Down Expand Up @@ -59,7 +59,7 @@ class Step(GraphObject):
with_prop = Property("with")
url = Property()

action = RelatedTo("src.workflow_components.composite_action.CompositeAction")
action = RelatedTo("raven_cycode.workflow_components.composite_action.CompositeAction")
reusable_workflow = RelatedTo("Workflow")
using_param = RelatedTo("StepCodeDependency")

Expand Down Expand Up @@ -87,7 +87,7 @@ def from_dict(obj_dict) -> "Step":
uses_string_obj = UsesString.analyze(uses_string=s.uses)
if uses_string_obj.type == UsesStringType.ACTION:
# Avoiding circular imports.
import src.workflow_components.composite_action as composite_action
import raven_cycode.workflow_components.composite_action as composite_action

obj = composite_action.get_or_create_composite_action(
uses_string_obj.get_full_path(s.path)
Expand Down
6 changes: 3 additions & 3 deletions tests/tests_init.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from os import getenv
from src.config.config import load_downloader_config, load_indexer_config
from src.downloader.download import download_account_workflows_and_actions
from src.indexer.index import index_downloaded_workflows_and_actions
from raven_cycode.config.config import load_downloader_config, load_indexer_config
from raven_cycode.downloader.download import download_account_workflows_and_actions
from raven_cycode.indexer.index import index_downloaded_workflows_and_actions


def init_integration_env():
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_composite_action.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import src.workflow_components.composite_action as composite_action
import raven_cycode.workflow_components.composite_action as composite_action
from tests.utils import load_test_config, assert_action_inputs

load_test_config()
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_dependency.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from tests.utils import load_test_config
import src.workflow_components.dependency as dependency
import raven_cycode.workflow_components.dependency as dependency

load_test_config()

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_parsing_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from src.workflow_components.parsing_utils import (
from raven_cycode.workflow_components.parsing_utils import (
parse_workflow_trigger,
parse_job_machine,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_report.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pathlib import Path
from src.config.config import LAST_QUERY_ID, QUERIES_PATH_DEFAULT
from raven_cycode.config.config import LAST_QUERY_ID, QUERIES_PATH_DEFAULT
from yaml import safe_load

query_dir = Path(__file__).parent.parent.parent / QUERIES_PATH_DEFAULT
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from tests.utils import load_test_config
import src.common.utils as utils
import raven_cycode.common.utils as utils

load_test_config()

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_workflow.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import src.workflow_components.workflow as workflow
import raven_cycode.workflow_components.workflow as workflow
from tests.utils import load_test_config, assert_reusable_workflow_inputs

load_test_config()
Expand Down
Loading