Skip to content

Conversation

@BassT
Copy link

@BassT BassT commented Sep 12, 2023

  • mongosh doesn't include the native method hostname() anymore and deprecated db.printSlaveReplicationInfo()
  • to make getMongoData.js compatible with mongosh
    • check if hostname() method exists, if not, use os.hostname() as hostname of host running mongosh
    • check if db.printSlaveReplicationInfo is deprecated and use db.printSecondaryReplicationInfo instead

* mongosh doesn't include the native hostname() method anymore
* to make getMongoData.js compatible with mongosh check if hostname() method exists
  * if not, put "N/A"
Copy link

@orca-security-us orca-security-us bot left a comment

Choose a reason for hiding this comment

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

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca

section = "server_info";
printInfo('Shell version', version, section);
printInfo('Shell hostname', hostname, section);
printInfo('Shell hostname', typeof hostname !== "undefined" ? hostname : function(){return "N/A"}, section);

Choose a reason for hiding this comment

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

instead of returning N/A mongosh supports os.hostname()

print("================================");
}
var _host = hostname();
var _host = typeof hostname !== "undefined" ? hostname() : "N/A";

Choose a reason for hiding this comment

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

same here we should use os.hostname()

* Use os.hostname instead of "N/A" for shell hostname
* Use db.printSecondaryReplicationInfo() instead of db.printSlaveReplicationInfo() if printSlaveReplicationInfo is deprecated
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.

2 participants