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

Release v0.4.0 #79

Merged
merged 28 commits into from
Sep 5, 2024
Merged

Release v0.4.0 #79

merged 28 commits into from
Sep 5, 2024

Conversation

jeremystretch
Copy link
Contributor

Enhancements

  • #52 - Introduce the max_branches config parameter
  • #71 - Ensure the consistent application of logging messages
  • #76 - Validate required configuration items on initialization

Bug Fixes

  • #57 - Avoid recording ChangeDiff records for unsupported object types
  • #59 - BranchAwareRouter should consider branching support for model when determining database connection to use
  • #61 - Fix transaction rollback when performing a dry run sync
  • #66 - Capture object representation on ChangeDiff when creating a new object within a branch
  • #69 - Represent null values for ChangeDiff fields consistently in REST API
  • #73 - Ensure all relevant branch diffs are updated when an object is modified in main

jeremystretch and others added 27 commits August 12, 2024 15:09
* Closes #52: Introduce the max_branches config parameter

* Improve documentation for config parameter
* add pyproject.toml

Signed-off-by: Michal Fiedorowicz <[email protected]>

* add docker-compose setup

based on NetBox v4.1-beta1-2.9.1 image with netbox_branching plugin installed

Signed-off-by: Michal Fiedorowicz <[email protected]>

* add Makefile recipes for docker compose

Signed-off-by: Michal Fiedorowicz <[email protected]>

* add GHA workflow to run lint and test

Signed-off-by: Michal Fiedorowicz <[email protected]>

* tidy up docker-compose.yaml

Signed-off-by: Michal Fiedorowicz <[email protected]>

* move workflow into correct directory

Signed-off-by: Michal Fiedorowicz <[email protected]>

* fix mounting of local_settings.py

Signed-off-by: Michal Fiedorowicz <[email protected]>

* ignore missing docstrings checks

Signed-off-by: Michal Fiedorowicz <[email protected]>

* add step for building documentation

Signed-off-by: Michal Fiedorowicz <[email protected]>

* catch make docker-compose-test exit code (test)

Signed-off-by: Michal Fiedorowicz <[email protected]>

* catch make docker-compose-test exit code (test 2)

Signed-off-by: Michal Fiedorowicz <[email protected]>

* tidy up make docker-compose-test

Signed-off-by: Michal Fiedorowicz <[email protected]>

* rename GHA job

Signed-off-by: Michal Fiedorowicz <[email protected]>

* ignore all missing docstrings

Signed-off-by: Michal Fiedorowicz <[email protected]>

* change workflow file ext

Signed-off-by: Michal Fiedorowicz <[email protected]>

* run tests with more native way with matrix of python versions

Signed-off-by: Michal Fiedorowicz <[email protected]>

* fix matrix with python version

Signed-off-by: Michal Fiedorowicz <[email protected]>

* fix test command for plugin

Signed-off-by: Michal Fiedorowicz <[email protected]>

* list tests

Signed-off-by: Michal Fiedorowicz <[email protected]>

* comment out exclude-package-data from pyproject.toml

Signed-off-by: Michal Fiedorowicz <[email protected]>

* tidy up

Signed-off-by: Michal Fiedorowicz <[email protected]>

* keep db when running tests

Signed-off-by: Michal Fiedorowicz <[email protected]>

* Remove v4.1-beta1 tag

---------

Signed-off-by: Michal Fiedorowicz <[email protected]>
Co-authored-by: Jeremy Stretch <[email protected]>
Copy link

@jit-ci jit-ci bot left a comment

Choose a reason for hiding this comment

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

❌ Jit has detected 5 important findings in this PR that you should review.
The findings are detailed below as separate comments.
It’s highly recommended that you fix these security issues before merge.

)
# Copy data from the source table
cursor.execute(
f"INSERT INTO {schema}.{table} SELECT * FROM public.{table}"
f"INSERT INTO {schema_table} SELECT * FROM {main_table}"
)
Copy link

Choose a reason for hiding this comment

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

Security control: Static Code Analysis Python Semgrep

Type: Python.Sqlalchemy.Security.Sqlalchemy-Execute-Raw-Query.Sqlalchemy-Execute-Raw-Query

Description: Avoiding SQL string concatenation: untrusted input concatenated with raw SQL query can result in SQL Injection. In order to execute raw query safely, prepared statement should be used. SQLAlchemy provides TextualSQL to easily used prepared statement with named parameters. For complex SQL composition, use SQL Expression Language or Schema Definition Language. In most cases, SQLAlchemy ORM will be a better option.

Severity: HIGH

Learn more about this issue


Jit Bot commands and options (e.g., ignore issue)

You can trigger Jit actions by commenting on this PR review:

  • #jit_ignore_fp Ignore and mark this specific single instance of finding as “False Positive”
  • #jit_ignore_accept Ignore and mark this specific single instance of finding as “Accept Risk”
  • #jit_ignore_type_in_file Ignore any finding of type "python.sqlalchemy.security.sqlalchemy-execute-raw-query.sqlalchemy-execute-raw-query" in netbox_branching/models/branches.py; future occurrences will also be ignored.
  • #jit_undo_ignore Undo ignore command

# Create the table in the new schema
cursor.execute(
f"CREATE TABLE {schema}.{table} ( LIKE public.{table} INCLUDING INDEXES )"
f"CREATE TABLE {schema_table} ( LIKE {main_table} INCLUDING INDEXES )"
)
Copy link

Choose a reason for hiding this comment

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

Security control: Static Code Analysis Python Semgrep

Type: Python.Sqlalchemy.Security.Sqlalchemy-Execute-Raw-Query.Sqlalchemy-Execute-Raw-Query

Description: Avoiding SQL string concatenation: untrusted input concatenated with raw SQL query can result in SQL Injection. In order to execute raw query safely, prepared statement should be used. SQLAlchemy provides TextualSQL to easily used prepared statement with named parameters. For complex SQL composition, use SQL Expression Language or Schema Definition Language. In most cases, SQLAlchemy ORM will be a better option.

Severity: HIGH

Learn more about this issue


Jit Bot commands and options (e.g., ignore issue)

You can trigger Jit actions by commenting on this PR review:

  • #jit_ignore_fp Ignore and mark this specific single instance of finding as “False Positive”
  • #jit_ignore_accept Ignore and mark this specific single instance of finding as “Accept Risk”
  • #jit_ignore_type_in_file Ignore any finding of type "python.sqlalchemy.security.sqlalchemy-execute-raw-query.sqlalchemy-execute-raw-query" in netbox_branching/models/branches.py; future occurrences will also be ignored.
  • #jit_undo_ignore Undo ignore command

cursor.execute(
f"CREATE TABLE {schema}.{table} ( LIKE public.{table} INCLUDING INDEXES )"
f"CREATE TABLE {schema_table} ( LIKE {main_table} INCLUDING INDEXES )"
)
Copy link

Choose a reason for hiding this comment

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

Security control: Static Code Analysis Python Semgrep

Type: Python.Sqlalchemy.Security.Sqlalchemy-Execute-Raw-Query.Sqlalchemy-Execute-Raw-Query

Description: Avoiding SQL string concatenation: untrusted input concatenated with raw SQL query can result in SQL Injection. In order to execute raw query safely, prepared statement should be used. SQLAlchemy provides TextualSQL to easily used prepared statement with named parameters. For complex SQL composition, use SQL Expression Language or Schema Definition Language. In most cases, SQLAlchemy ORM will be a better option.

Severity: HIGH

Learn more about this issue


Jit Bot commands and options (e.g., ignore issue)

You can trigger Jit actions by commenting on this PR review:

  • #jit_ignore_fp Ignore and mark this specific single instance of finding as “False Positive”
  • #jit_ignore_accept Ignore and mark this specific single instance of finding as “Accept Risk”
  • #jit_ignore_type_in_file Ignore any finding of type "python.sqlalchemy.security.sqlalchemy-execute-raw-query.sqlalchemy-execute-raw-query" in netbox_branching/models/branches.py; future occurrences will also be ignored.
  • #jit_undo_ignore Undo ignore command

# Set the default value for the ID column to the sequence associated with the source table
cursor.execute(
f"ALTER TABLE {schema}.{table} ALTER COLUMN id SET DEFAULT nextval('public.{table}_id_seq')"
f"ALTER TABLE {schema_table} ALTER COLUMN id SET DEFAULT nextval(%s)", [sequence_name]
)
Copy link

Choose a reason for hiding this comment

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

Security control: Static Code Analysis Python Semgrep

Type: Python.Sqlalchemy.Security.Sqlalchemy-Execute-Raw-Query.Sqlalchemy-Execute-Raw-Query

Description: Avoiding SQL string concatenation: untrusted input concatenated with raw SQL query can result in SQL Injection. In order to execute raw query safely, prepared statement should be used. SQLAlchemy provides TextualSQL to easily used prepared statement with named parameters. For complex SQL composition, use SQL Expression Language or Schema Definition Language. In most cases, SQLAlchemy ORM will be a better option.

Severity: HIGH

Learn more about this issue


Jit Bot commands and options (e.g., ignore issue)

You can trigger Jit actions by commenting on this PR review:

  • #jit_ignore_fp Ignore and mark this specific single instance of finding as “False Positive”
  • #jit_ignore_accept Ignore and mark this specific single instance of finding as “Accept Risk”
  • #jit_ignore_type_in_file Ignore any finding of type "python.sqlalchemy.security.sqlalchemy-execute-raw-query.sqlalchemy-execute-raw-query" in netbox_branching/models/branches.py; future occurrences will also be ignored.
  • #jit_undo_ignore Undo ignore command

cursor.execute(
f"ALTER TABLE {schema}.{table} "
f"ALTER COLUMN id SET DEFAULT nextval('public.{table}_id_seq')"
f"ALTER TABLE {schema_table} ALTER COLUMN id SET DEFAULT nextval(%s)", [sequence_name]
)
Copy link

Choose a reason for hiding this comment

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

Security control: Static Code Analysis Python Semgrep

Type: Python.Sqlalchemy.Security.Sqlalchemy-Execute-Raw-Query.Sqlalchemy-Execute-Raw-Query

Description: Avoiding SQL string concatenation: untrusted input concatenated with raw SQL query can result in SQL Injection. In order to execute raw query safely, prepared statement should be used. SQLAlchemy provides TextualSQL to easily used prepared statement with named parameters. For complex SQL composition, use SQL Expression Language or Schema Definition Language. In most cases, SQLAlchemy ORM will be a better option.

Severity: HIGH

Learn more about this issue


Jit Bot commands and options (e.g., ignore issue)

You can trigger Jit actions by commenting on this PR review:

  • #jit_ignore_fp Ignore and mark this specific single instance of finding as “False Positive”
  • #jit_ignore_accept Ignore and mark this specific single instance of finding as “Accept Risk”
  • #jit_ignore_type_in_file Ignore any finding of type "python.sqlalchemy.security.sqlalchemy-execute-raw-query.sqlalchemy-execute-raw-query" in netbox_branching/models/branches.py; future occurrences will also be ignored.
  • #jit_undo_ignore Undo ignore command

Copy link
Contributor

@arthanson arthanson left a comment

Choose a reason for hiding this comment

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

Looks correct, versions are updated.

@jeremystretch jeremystretch merged commit 3332632 into release Sep 5, 2024
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants