Skip to content
This repository was archived by the owner on Sep 24, 2025. It is now read-only.

chore: makefile actions#340

Merged
tty47 merged 1 commit intomainfrom
feat/makefile-kong-actions
May 16, 2025
Merged

chore: makefile actions#340
tty47 merged 1 commit intomainfrom
feat/makefile-kong-actions

Conversation

@tty47
Copy link
Copy Markdown
Collaborator

@tty47 tty47 commented May 16, 2025

Overview

Summary by CodeRabbit

  • New Features

    • Added commands to manage and update authentication credentials for the Swagger UI.
    • Introduced commands to list authentication credentials and verify configuration details.
  • Enhancements

    • Improved the setup process for Swagger UI by adding authentication and route management steps.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented May 16, 2025

Walkthrough

The Makefile was updated to enhance Kong API gateway management. The kong-setup target now configures a dedicated Swagger UI route with basic authentication. Three new targets were added: kong-list-auth for listing credentials, kong-update-auth for updating passwords, and kong-verify for verifying Kong's configuration.

Changes

File Change Summary
Makefile Enhanced kong-setup to add Swagger UI route and basic-auth; added kong-list-auth, kong-update-auth, and kong-verify targets for managing and verifying Kong authentication and configuration.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant Makefile
    participant KongAPI as Kong API

    Dev->>Makefile: make kong-setup
    Makefile->>KongAPI: Create Swagger UI route
    Makefile->>KongAPI: Attach basic-auth plugin to route
    Makefile->>KongAPI: Create basic-auth credential (swagger/secret)

    Dev->>Makefile: make kong-list-auth
    Makefile->>KongAPI: List basic-auth credentials for 'talisuser'
    KongAPI-->>Makefile: Return credentials

    Dev->>Makefile: make kong-update-auth PASSWORD=newpass
    Makefile->>KongAPI: Check for existing credential
    alt Credential exists
        Makefile->>KongAPI: Delete existing credential
    end
    Makefile->>KongAPI: Create new credential with PASSWORD

    Dev->>Makefile: make kong-verify
    Makefile->>KongAPI: Query services, routes, plugins, consumers
    KongAPI-->>Makefile: Return configuration
Loading

Poem

🐇
In the warren of Makefiles deep,
New targets hop and secrets keep.
Swagger’s guarded, routes align,
Credentials checked—now all is fine.
With Kong commands both new and spry,
The rabbit waves a whiskered hi!
🥕

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


Note

⚡️ Faster reviews with caching

CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.
Enjoy the performance boost—your workflow just got faster.


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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@tty47 tty47 self-assigned this May 16, 2025
@celestia-bot celestia-bot requested a review from a team May 16, 2025 14:31
@tty47 tty47 requested a review from a team May 16, 2025 14:31
@tty47 tty47 added the chore Chore label May 16, 2025
@tty47 tty47 enabled auto-merge (squash) May 16, 2025 14:32
@tty47 tty47 disabled auto-merge May 16, 2025 14:33
@tty47 tty47 merged commit 55f5838 into main May 16, 2025
16 of 17 checks passed
@tty47 tty47 deleted the feat/makefile-kong-actions branch May 16, 2025 14:33
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
Makefile (1)

205-243: 🛠️ Refactor suggestion

⚠️ Potential issue

Raise idempotency and security concerns for kong-setup.
The kong-setup target hardcodes credentials (talis/talis123) and blindly POSTs resources, which can lead to failures on repeated runs and exposes secrets in version control.

  • Parameterize username/password via variables or environment
  • Add existence checks (e.g., GET before POST) or switch to idempotent HTTP methods (PUT)
  • Fail early on errors (set -euo pipefail)
+KONG_SWAGGER_USER ?= talis
+KONG_SWAGGER_PASS ?= $(or $(KONG_SWAGGER_PASS),talis123)
 ...
-	curl -i -X POST http://localhost:8001/consumers/talisuser/basic-auth \
-	  --data "username=talis" \
-	  --data "password=talis123"
+	@echo "Creating/updating basic-auth credential for swagger..."
+EXISTING_ID=$$(curl -s http://localhost:8001/consumers/talisuser/basic-auth | jq -r '.data[] | select(.username=="$(KONG_SWAGGER_USER)") | .id'); \
+if [ -n "$$EXISTING_ID" ]; then \
+  curl -i -X DELETE http://localhost:8001/consumers/talisuser/basic-auth/$$EXISTING_ID; \
+fi; \
+curl -i -X POST http://localhost:8001/consumers/talisuser/basic-auth \
+  --data "username=$(KONG_SWAGGER_USER)" \
+  --data "password=$(KONG_SWAGGER_PASS)"
🧹 Nitpick comments (2)
Makefile (2)

245-250: Add basic error handling and CLI checks to kong-list-auth.
The kong-list-auth target assumes curl and jq exist and returns JSON only. Consider:

  • Failing early if dependencies are missing
  • Adding HTTP status validation (-f or checking response code)
  • Optionally outputting a user-friendly message on failure
kong-list-auth:
	@command -v curl >/dev/null || (echo "curl not found" && exit 1)
	@command -v jq >/dev/null || (echo "jq not found" && exit 1)
	@echo "Listing basic auth credentials..."
	curl -f -s http://localhost:8001/consumers/talisuser/basic-auth | jq .

274-286: Improve readability in kong-verify output.
Currently echo "\nChecking services..." prints the literal \n. Switch to echo -e or separate commands, and validate JSON tool availability.

kong-verify:
	@command -v jq >/dev/null || (echo "jq not found" && exit 1)
	@echo
	@echo "Checking services..."
	curl -f -s http://localhost:8001/services | jq .
	@echo
	@echo "Checking routes..."
	curl -f -s http://localhost:8001/routes | jq .
	# ... etc.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between d4fcfa9 and 73b2907.

📒 Files selected for processing (1)
  • Makefile (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: docker-security-build / docker-build (GHCR; ghcr.io/celestiaorg/talis)
  • GitHub Check: docker-compose
  • GitHub Check: test

Comment thread Makefile
Comment on lines +251 to +273
## kong-update-auth: Update basic auth password (usage: make kong-update-auth PASSWORD=your_new_password)
kong-update-auth:
@if [ -z "$(PASSWORD)" ]; then \
echo "Error: PASSWORD is required. Usage: make kong-update-auth PASSWORD=your_new_password"; \
exit 1; \
fi
@echo "Updating basic auth password..."
@CREDENTIAL_ID=$$(curl -s http://localhost:8001/consumers/talisuser/basic-auth | jq -r '.data[0].id'); \
if [ -n "$$CREDENTIAL_ID" ]; then \
echo "Deleting existing credential $$CREDENTIAL_ID..."; \
curl -i -X DELETE http://localhost:8001/consumers/talisuser/basic-auth/$$CREDENTIAL_ID; \
echo "Creating new credential..."; \
curl -i -X POST http://localhost:8001/consumers/talisuser/basic-auth \
--data "username=talis" \
--data "password=$(PASSWORD)"; \
else \
echo "No existing credential found. Creating new one..."; \
curl -i -X POST http://localhost:8001/consumers/talisuser/basic-auth \
--data "username=talis" \
--data "password=$(PASSWORD)"; \
fi
.PHONY: kong-update-auth

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Prevent shell injection and enforce robust update logic in kong-update-auth.
Interpolating $(PASSWORD) directly in the curl command opens you up to shell injection. Also, if multiple credentials exist, only the first is removed.

  • Quote and sanitize PASSWORD (e.g., allow only alphanumeric)
  • Loop through or filter credentials by username
  • Set strict shell flags (set -euo pipefail) at the top of the recipe
kong-update-auth:
+	@set -euo pipefail
 	@if [ -z "$(PASSWORD)" ]; then \
 		echo "Error: PASSWORD is required. Usage: make kong-update-auth PASSWORD=<new_password>"; \
 		exit 1; \
 	fi
-	@CREDENTIAL_ID=$$(curl -s http://localhost:8001/consumers/talisuser/basic-auth | jq -r '.data[0].id'); \
+	@SAFE_PASS=$$(printf '%s' "$(PASSWORD)" | sed 's/[^a-zA-Z0-9]//g'); \
+	@IDS=$$(curl -s http://localhost:8001/consumers/talisuser/basic-auth | jq -r '.data[] | select(.username=="talis") | .id'); \
+	for ID in $$IDS; do \
+	  curl -s -i -X DELETE http://localhost:8001/consumers/talisuser/basic-auth/$$ID; \
+	done; \
 	echo "Creating new credential..."; \
-	curl -i -X POST http://localhost:8001/consumers/talisuser/basic-auth \
-	  --data "username=talis" \
-	  --data "password=$(PASSWORD)"; \
+	curl -s -i -X POST http://localhost:8001/consumers/talisuser/basic-auth \
+	  --data "username=talis" \
+	  --data "password=$$SAFE_PASS";

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In the Makefile from lines 251 to 273, the kong-update-auth target directly
interpolates the PASSWORD variable into curl commands, risking shell injection,
and only deletes the first credential if multiple exist. To fix this, add strict
shell flags (set -euo pipefail) at the start of the recipe for robustness,
sanitize and quote the PASSWORD variable to allow only alphanumeric characters
to prevent injection, and modify the logic to loop through all credentials for
the user talisuser, deleting each before creating the new credential.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

chore Chore

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants