Skip to content

Conversation

@tipusinghaw
Copy link
Contributor

@tipusinghaw tipusinghaw commented Aug 7, 2025

This pull request introduces significant improvements and refactoring across the agent provisioning and interaction flow:

  • Added API key support in AFJ agent startup scripts (start_agent.sh, start_agent_ecs.sh)
  • Refactored URL construction logic across services (agent, connection, issuance, verification) by introducing a centralized getAgentUrl() utility
  • Removed OrgAgentType-based conditional logic in favor of a standardized URL mapping approach
  • Updated the getOrgAgentApiKey method and introduced getTenantToken for improved token management and secure retrieval
  • Enhanced agent spin-up scripts to capture and persist agent API keys from logs
  • Minor ESLint fix: added newline at the end of .eslintrc.js

tipusinghaw and others added 4 commits August 5, 2025 09:56
* feat: added logic for updated routes for agent

Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com>

* refactor: uncommented required code

Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com>

* feat:added logic to get token from cloudwatch

Signed-off-by: Sahil Kamble <sahil.kamble@ayanworks.com>

* feat: update credo image in taskdef

Signed-off-by: Sahil Kamble <sahil.kamble@ayanworks.com>

* feat: change service name for testing

Signed-off-by: Sahil Kamble <sahil.kamble@ayanworks.com>

* chore: WIP

Signed-off-by: Sahil Kamble <sahil.kamble@ayanworks.com>

* debug: added logs for agent details

Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com>

* refactor:removed console logs

Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com>

* refactor:removed commented code

Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com>

* feat: added token for old wallet

Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com>

* refactor: cloud wallet urls and token changes

Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com>

* refactor: removed logs from shell scripts

Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com>

* refactor: resolve comment

Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com>

* refactor: resolve comments for getOrgAgentApiKey

Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com>

* refactor: agent service comments

Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com>

---------

Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com>
Signed-off-by: Sahil Kamble <sahil.kamble@ayanworks.com>
Co-authored-by: Sahil Kamble <sahil.kamble@ayanworks.com>
Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com>
* fix: schema by id

Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com>

* fix: schema by id

Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com>

---------

Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com>
* fix: schema by id

Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com>

* fix: schema by id

Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com>

* fix: duplicate URL creation

Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com>

* fix: added await in common method

Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com>

* fix: added logic for get token

Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com>

* fix: polygon routes

Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com>

---------

Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com>
walletStorageHost,
walletStoragePassword,
walletStoragePort,
walletStorageUser,

Check warning

Code scanning / CodeQL

Shell command built from environment values Medium

This shell command depends on an uncontrolled
absolute path
.

Copilot Autofix

AI 6 months ago

To fix the problem, we should avoid constructing a shell command as a single string and passing it to exec. Instead, we should use execFile (or execFileSync if synchronous execution is desired), which allows us to specify the command and its arguments separately. This prevents shell interpretation of arguments and mitigates the risk of shell injection.

Detailed steps:

  • Parse the shell script path and arguments separately.
  • Use execFile to run the shell script, passing the arguments as an array.
  • Ensure that all arguments are passed as individual array elements, not concatenated into a single string.
  • Update the code in apps/agent-provisioning/src/agent-provisioning.service.ts at lines 43–45 to use execFile instead of exec.
  • No additional dependencies are required, as execFile is part of Node.js's child_process module.

Suggested changeset 1
apps/agent-provisioning/src/agent-provisioning.service.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/apps/agent-provisioning/src/agent-provisioning.service.ts b/apps/agent-provisioning/src/agent-provisioning.service.ts
--- a/apps/agent-provisioning/src/agent-provisioning.service.ts
+++ b/apps/agent-provisioning/src/agent-provisioning.service.ts
@@ -42,5 +42,30 @@
         // The wallet provision command is used to invoke a shell script
-        const walletProvision = `${process.cwd() + process.env.AFJ_AGENT_SPIN_UP} ${orgId} "${externalIp}" "${walletName}" "${walletPassword}" ${seed} ${webhookEndpoint} ${walletStorageHost} ${walletStoragePort} ${walletStorageUser} ${walletStoragePassword} ${containerName} ${protocol} ${tenant} ${credoImage} "${indyLedger}" ${inboundEndpoint} ${process.env.SCHEMA_FILE_SERVER_URL} ${apiKey} ${process.env.AGENT_HOST} ${process.env.AWS_ACCOUNT_ID} ${process.env.S3_BUCKET_ARN} ${process.env.CLUSTER_NAME} ${process.env.TESKDEFINITION_FAMILY}`;
+        const scriptPath = process.cwd() + process.env.AFJ_AGENT_SPIN_UP;
+        const walletProvisionArgs = [
+          orgId,
+          externalIp,
+          walletName,
+          walletPassword,
+          seed,
+          webhookEndpoint,
+          walletStorageHost,
+          walletStoragePort,
+          walletStorageUser,
+          walletStoragePassword,
+          containerName,
+          protocol,
+          tenant,
+          credoImage,
+          indyLedger,
+          inboundEndpoint,
+          process.env.SCHEMA_FILE_SERVER_URL,
+          apiKey,
+          process.env.AGENT_HOST,
+          process.env.AWS_ACCOUNT_ID,
+          process.env.S3_BUCKET_ARN,
+          process.env.CLUSTER_NAME,
+          process.env.TESKDEFINITION_FAMILY
+        ];
         const spinUpResponse: object = new Promise(async (resolve) => {
-          await exec(walletProvision, async (err, stdout, stderr) => {
+          await execFile(scriptPath, walletProvisionArgs, async (err, stdout, stderr) => {
             this.logger.log(`shell script output: ${stdout}`);
EOF
@@ -42,5 +42,30 @@
// The wallet provision command is used to invoke a shell script
const walletProvision = `${process.cwd() + process.env.AFJ_AGENT_SPIN_UP} ${orgId} "${externalIp}" "${walletName}" "${walletPassword}" ${seed} ${webhookEndpoint} ${walletStorageHost} ${walletStoragePort} ${walletStorageUser} ${walletStoragePassword} ${containerName} ${protocol} ${tenant} ${credoImage} "${indyLedger}" ${inboundEndpoint} ${process.env.SCHEMA_FILE_SERVER_URL} ${apiKey} ${process.env.AGENT_HOST} ${process.env.AWS_ACCOUNT_ID} ${process.env.S3_BUCKET_ARN} ${process.env.CLUSTER_NAME} ${process.env.TESKDEFINITION_FAMILY}`;
const scriptPath = process.cwd() + process.env.AFJ_AGENT_SPIN_UP;
const walletProvisionArgs = [
orgId,
externalIp,
walletName,
walletPassword,
seed,
webhookEndpoint,
walletStorageHost,
walletStoragePort,
walletStorageUser,
walletStoragePassword,
containerName,
protocol,
tenant,
credoImage,
indyLedger,
inboundEndpoint,
process.env.SCHEMA_FILE_SERVER_URL,
apiKey,
process.env.AGENT_HOST,
process.env.AWS_ACCOUNT_ID,
process.env.S3_BUCKET_ARN,
process.env.CLUSTER_NAME,
process.env.TESKDEFINITION_FAMILY
];
const spinUpResponse: object = new Promise(async (resolve) => {
await exec(walletProvision, async (err, stdout, stderr) => {
await execFile(scriptPath, walletProvisionArgs, async (err, stdout, stderr) => {
this.logger.log(`shell script output: ${stdout}`);
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
@coderabbitai
Copy link

coderabbitai bot commented Aug 7, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch develop

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.
  • 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.

Support

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

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 generate unit tests to generate unit tests for 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.

@tipusinghaw tipusinghaw self-assigned this Aug 7, 2025
@GHkrishna GHkrishna added bug Something isn't working enhancement Improving existing code or adding enhancement labels Aug 7, 2025
…r images (#1376)

Signed-off-by: Sahil Kamble <sahil.kamble@ayanworks.com>
Signed-off-by: Krishna Waske <krishna.waske@ayanworks.com>
@tipusinghaw tipusinghaw closed this Aug 7, 2025
@tipusinghaw tipusinghaw reopened this Aug 7, 2025
Signed-off-by: Tipu_Singh <tipu.singh@ayanworks.com>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Aug 7, 2025

@tipusinghaw tipusinghaw merged commit 1fb387f into qa Aug 7, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement Improving existing code or adding enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants