dockerize fetch-nest-dump to avoid local dependency on poetry #4581
dockerize fetch-nest-dump to avoid local dependency on poetry #4581devnchill wants to merge 2 commits intoOWASP:mainfrom
Conversation
WalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Warning
CodeRabbit couldn't request changes on this pull request because it doesn't have sufficient GitHub permissions.
Please grant CodeRabbit Pull requests: Read and write permission and re-run the review.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@backend/Makefile`:
- Around line 123-130: The fetch-nest-dump Makefile target should be fixed:
remove the commented-out legacy python command, stop running a host chmod with
unsafe mode 757 (either ensure ownership in Dockerfile.local or if kept, guard
it with a directory existence check and use 775), replace the backticked string
around nest-backend (which triggers command substitution) with a literal name or
drop quotes, call docker compose with the same compose file flag used elsewhere
(e.g., -f docker-compose/local/compose.yaml) or reuse the exec-backend-command
pattern instead of relying solely on --project-name, and remove the debug ls -l
backend/data or replace it with a concise success echo; also review
upload-nest-dump to make its poetry invocation consistent (dockerized) or
document why it differs.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 30a39de3-f78a-4d5f-9908-cd3eb8802901
📒 Files selected for processing (1)
backend/Makefile
| fetch-nest-dump: ## Download backend/data/nest.dump from S3 if the remote copy changed | ||
| @cd backend && poetry run python -m scripts.fetch_nest_dump | ||
| # @cd backend && poetry run python -m scripts.fetch_nest_dump | ||
| @echo "changing permission of /backend/data" | ||
| @chmod 757 backend/data | ||
| @echo "fetching data inside docker container `nest-backend`" | ||
| @docker compose --project-name nest-local exec backend poetry run python -m scripts.fetch_nest_dump | ||
| @echo "Check if it worked" | ||
| @ls -l backend/data |
There was a problem hiding this comment.
Several issues in the reworked fetch-nest-dump target.
-
Line 126 —
chmod 757is world-writable and runs on the host. Mode757grantsrwxto others, which is a needless privilege grant on the developer's host filesystem. The proper fix is to ensure theowaspuser in the backend image owns/home/owasp/data(viaDockerfile.local), not to loosen host permissions at every invocation. At minimum use775. Also, because this runs on the host, it requires that the invoking host user has permission to chmod that directory (won't work if it was previously created as root by Docker). -
Line 127 — backticks around
`nest-backend`trigger command substitution.makepasses the line to the shell, which will try to executenest-backendand fail withnest-backend: command not found, polluting output. Use single quotes or drop the backticks. -
Line 124 — remove commented-out legacy command rather than leaving it as dead code.
-
Line 128 — missing compose file reference. Every other
docker composeinvocation in this Makefile passes-f docker-compose/<env>/compose.yaml(seerun-backend-e2e,run-backend-fuzz,test-fuzz). Relying solely on--project-name nest-localrequires thenest-backendcontainer to already be running and depends on docker's project-name resolution. If the stack isn't up, this fails with a confusing error. Consider either usingdocker exec -i nest-backend …(consistent withexec-backend-command) or passing-f docker-compose/local/compose.yaml. -
Line 130 —
ls -l backend/datalooks like a debug leftover. Either drop it or replace with a meaningful success message. -
Consistency gap with
upload-nest-dump(line 104). The PR's stated goal is to remove the local poetry dependency, butupload-nest-dumpstill runspoetry runon the host. Consider the same dockerized approach there for consistency, or at least document why it's intentionally different.
🛠️ Proposed fix
fetch-nest-dump: ## Download backend/data/nest.dump from S3 if the remote copy changed
- # `@cd` backend && poetry run python -m scripts.fetch_nest_dump
- `@echo` "changing permission of /backend/data"
- `@chmod` 757 backend/data
- `@echo` "fetching data inside docker container `nest-backend`"
- `@docker` compose --project-name nest-local exec backend poetry run python -m scripts.fetch_nest_dump
- `@echo` "Check if it worked"
- `@ls` -l backend/data
+ `@echo` "Fetching nest.dump inside the nest-backend container"
+ `@CMD`="poetry run python -m scripts.fetch_nest_dump" $(MAKE) exec-backend-command(Preferred: fix directory ownership in docker/backend/Dockerfile.local so no host chmod is needed. If a host-side chmod must stay, use 775 and guard it with [ -d backend/data ] && chmod 775 backend/data || true.)
🧰 Tools
🪛 checkmake (0.3.2)
[warning] 123-123: Target body for "fetch-nest-dump" exceeds allowed length of 5 lines (7).
(maxbodylength)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@backend/Makefile` around lines 123 - 130, The fetch-nest-dump Makefile target
should be fixed: remove the commented-out legacy python command, stop running a
host chmod with unsafe mode 757 (either ensure ownership in Dockerfile.local or
if kept, guard it with a directory existence check and use 775), replace the
backticked string around nest-backend (which triggers command substitution) with
a literal name or drop quotes, call docker compose with the same compose file
flag used elsewhere (e.g., -f docker-compose/local/compose.yaml) or reuse the
exec-backend-command pattern instead of relying solely on --project-name, and
remove the debug ls -l backend/data or replace it with a concise success echo;
also review upload-nest-dump to make its poetry invocation consistent
(dockerized) or document why it differs.
There was a problem hiding this comment.
2 issues found across 1 file
Confidence score: 2/5
- There are two high-confidence issues in
backend/Makefile, including a security-sensitive permission setting, so this carries elevated merge risk. - The
chmod 757onbackend/datais the most severe concern: world-writable permissions are unnecessarily broad and can expose the host filesystem to misuse; tightening to safer permissions/ownership is recommended before merge. - Backticks around
nest-backendinbackend/Makefilewill trigger shell command substitution, which can producecommand not founderrors and break expected script behavior. - Pay close attention to
backend/Makefile- fix unsafe directory permissions and replace backticks to avoid shell substitution failures.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="backend/Makefile">
<violation number="1" location="backend/Makefile:126">
P1: `chmod 757` grants world-writable and world-executable permissions (`rwxr-xrwx`) to `backend/data`, which is an unnecessary security risk on the host filesystem. Use `775` at minimum, or better yet, fix directory ownership inside the Docker image (e.g., in `Dockerfile.local`) so no host-side `chmod` is needed.</violation>
<violation number="2" location="backend/Makefile:127">
P2: Backticks around `nest-backend` will be interpreted as shell command substitution. The shell will try to execute `nest-backend` as a command (which doesn't exist), producing a "command not found" error and garbled output. Use single quotes or remove the backticks entirely.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
|
@arkid15r in cd docs && poetry updatesince aim of our issue initially was to bypass poetry overall locally , i am wondering if i should work on dockerizing poetry for updating docs as well or should this pr just be focused on |



Proposed change
Resolves #4536
Add the PR description here.
fetch-nest-dump.pyinsidenest-backendcontainernest.dumpfile inbackend/datato be later used for storing/updating data in databasesChecklist
make check-testlocally: all warnings addressed, tests passed