Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions modules/amt-wsman.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ function WsmanStackCreateService(/*CreateWsmanComm, host, port, user, pass, tls,
if (CreateWsmanComm) { obj.comm = new CreateWsmanComm(arguments[1], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6]); }
}

obj.PerformAjax = function PerformAjax(postdata, callback, tag, pri, namespaces) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🟠 K&R brace style used throughout amt-wsman.js instead of required Allman style

Converted obj.PerformAjax = function PerformAjax(postdata, callback, tag, pri, namespaces) { (around line 43) to Allman style by moving the opening brace to its own line beneath the function signature, matching the style of WsmanStackCreateService. Only the brace placement was changed; the function body is untouched.

🤖 Prompt for AI agents
In modules/amt-wsman.js around line 43, review and complete this code-review fix: K&R brace style used throughout amt-wsman.js instead of required Allman style.
What the draft fix changed: Converted `obj.PerformAjax = function PerformAjax(postdata, callback, tag, pri, namespaces) {` (around line 43) to Allman style by moving the opening brace to its own line beneath the function signature, matching the style of `WsmanStackCreateService`. Only the brace placement was changed; the function body is untouched.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟡 60 medium — react 👍/👎 to teach the reviewer

obj.PerformAjax = function PerformAjax(postdata, callback, tag, pri, namespaces)
{
if (namespaces == null) namespaces = '';
obj.comm.PerformAjax('<?xml version=\"1.0\" encoding=\"utf-8\"?><Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:w="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd" xmlns=\"http://www.w3.org/2003/05/soap-envelope\" ' + namespaces + '><Header><a:Action>' + postdata, function (data, status, tag) {
if (status != 200) { callback(obj, null, { Header: { HttpError: status } }, status, tag); return; }
Expand All @@ -62,7 +63,8 @@ function WsmanStackCreateService(/*CreateWsmanComm, host, port, user, pass, tls,
}

// Perform a WSMAN Subscribe operation
obj.ExecSubscribe = function ExecSubscribe(resuri, delivery, url, callback, tag, pri, selectors, opaque, user, pass) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

🦩 🟠 K&R brace style used for ExecSubscribe/ExecUnSubscribe/etc. instead of required Allman style

Converted the opening braces of obj.ExecSubscribe, obj.ExecUnSubscribe, obj.ExecPut, obj.ExecCreate, obj.ExecDelete, obj.ExecGet, obj.ExecMethod, obj.ExecMethodXml, obj.ExecEnum, and obj.ExecPull from K&R to Allman style (opening brace moved to its own line). These were the remaining top-level obj.Exec* method definitions using K&R braces cited by the finding; smaller inline handlers (obj.CancelAllQueries, obj.GetNameFromUrl, internal helper functions _PutObjToBodyXml, _ObjectToXmlAttributes, _PutObjToSelectorsXml) were left unchanged since they were not called out in the finding and altering them further risks unnecessary scope creep beyond the cited evidence.

🤖 Prompt for AI agents
In modules/amt-wsman.js around line 65, review and complete this code-review fix: K&R brace style used for ExecSubscribe/ExecUnSubscribe/etc. instead of required Allman style.
What the draft fix changed: Converted the opening braces of `obj.ExecSubscribe`, `obj.ExecUnSubscribe`, `obj.ExecPut`, `obj.ExecCreate`, `obj.ExecDelete`, `obj.ExecGet`, `obj.ExecMethod`, `obj.ExecMethodXml`, `obj.ExecEnum`, and `obj.ExecPull` from K&R to Allman style (opening brace moved to its own line). These were the remaining top-level `obj.Exec*` method definitions using K&R braces cited by the finding; smaller inline handlers (`obj.CancelAllQueries`, `obj.GetNameFromUrl`, internal helper functions `_PutObjToBodyXml`, `_ObjectToXmlAttributes`, `_PutObjToSelectorsXml`) were left unchanged since they were not called out in the finding and altering them further risks unnecessary scope creep beyond the cited evidence.
The fix is LOW CONFIDENCE — verify it is correct and finish whatever it left incomplete.

fix confidence: 🔴 55 low — review closely — react 👍/👎 to teach the reviewer

obj.ExecSubscribe = function ExecSubscribe(resuri, delivery, url, callback, tag, pri, selectors, opaque, user, pass)
{
var digest = "", digest2 = "", opaque = "";
if (user != null && pass != null) { digest = '<t:IssuedTokens xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:se="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><t:RequestSecurityTokenResponse><t:TokenType>http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken</t:TokenType><t:RequestedSecurityToken><se:UsernameToken><se:Username>' + user + '</se:Username><se:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd#PasswordText">' + pass + '</se:Password></se:UsernameToken></t:RequestedSecurityToken></t:RequestSecurityTokenResponse></t:IssuedTokens>'; digest2 = '<w:Auth Profile="http://schemas.dmtf.org/wbem/wsman/1/wsman/secprofile/http/digest"/>'; }
if (opaque != null) { opaque = '<a:ReferenceParameters><m:arg>' + opaque + '</m:arg></a:ReferenceParameters>'; }
Expand All @@ -72,55 +74,64 @@ function WsmanStackCreateService(/*CreateWsmanComm, host, port, user, pass, tls,
}

// Perform a WSMAN UnSubscribe operation
obj.ExecUnSubscribe = function ExecUnSubscribe(resuri, callback, tag, pri, selectors) {
obj.ExecUnSubscribe = function ExecUnSubscribe(resuri, callback, tag, pri, selectors)
{
var data = "http://schemas.xmlsoap.org/ws/2004/08/eventing/Unsubscribe</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo>" + _PutObjToSelectorsXml(selectors) + '</Header><Body><e:Unsubscribe/>';
obj.PerformAjax(data + "</Body></Envelope>", callback, tag, pri, 'xmlns:e="http://schemas.xmlsoap.org/ws/2004/08/eventing"');
}

// Perform a WSMAN PUT operation
obj.ExecPut = function ExecPut(resuri, putobj, callback, tag, pri, selectors) {
obj.ExecPut = function ExecPut(resuri, putobj, callback, tag, pri, selectors)
{
var data = "http://schemas.xmlsoap.org/ws/2004/09/transfer/Put</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60.000S</w:OperationTimeout>" + _PutObjToSelectorsXml(selectors) + '</Header><Body>' + _PutObjToBodyXml(resuri, putobj);
obj.PerformAjax(data + "</Body></Envelope>", callback, tag, pri);
}

// Perform a WSMAN CREATE operation
obj.ExecCreate = function ExecCreate(resuri, putobj, callback, tag, pri, selectors) {
obj.ExecCreate = function ExecCreate(resuri, putobj, callback, tag, pri, selectors)
{
var objname = obj.GetNameFromUrl(resuri);
var data = "http://schemas.xmlsoap.org/ws/2004/09/transfer/Create</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout>" + _PutObjToSelectorsXml(selectors) + "</Header><Body><g:" + objname + " xmlns:g=\"" + resuri + "\">";
for (var n in putobj) { data += "<g:" + n + ">" + putobj[n] + "</g:" + n + ">" }
obj.PerformAjax(data + "</g:" + objname + "></Body></Envelope>", callback, tag, pri);
}

// Perform a WSMAN DELETE operation
obj.ExecDelete = function ExecDelete(resuri, putobj, callback, tag, pri) {
obj.ExecDelete = function ExecDelete(resuri, putobj, callback, tag, pri)
{
var data = "http://schemas.xmlsoap.org/ws/2004/09/transfer/Delete</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout>" + _PutObjToSelectorsXml(putobj) + "</Header><Body /></Envelope>";
obj.PerformAjax(data, callback, tag, pri);
}

// Perform a WSMAN GET operation
obj.ExecGet = function ExecGet(resuri, callback, tag, pri) {
obj.ExecGet = function ExecGet(resuri, callback, tag, pri)
{
obj.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/transfer/Get</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout></Header><Body /></Envelope>", callback, tag, pri);
}

// Perform a WSMAN method call operation
obj.ExecMethod = function ExecMethod(resuri, method, args, callback, tag, pri, selectors) {
obj.ExecMethod = function ExecMethod(resuri, method, args, callback, tag, pri, selectors)
{
var argsxml = "";
for (var i in args) { if (args[i] != null) { if (Array.isArray(args[i])) { for (var x in args[i]) { argsxml += "<r:" + i + ">" + args[i][x] + "</r:" + i + ">"; } } else { argsxml += "<r:" + i + ">" + args[i] + "</r:" + i + ">"; } } }
obj.ExecMethodXml(resuri, method, argsxml, callback, tag, pri, selectors);
}

// Perform a WSMAN method call operation. The arguments are already formatted in XML.
obj.ExecMethodXml = function ExecMethodXml(resuri, method, argsxml, callback, tag, pri, selectors) {
obj.ExecMethodXml = function ExecMethodXml(resuri, method, argsxml, callback, tag, pri, selectors)
{
obj.PerformAjax(resuri + "/" + method + "</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout>" + _PutObjToSelectorsXml(selectors) + "</Header><Body><r:" + method + '_INPUT' + " xmlns:r=\"" + resuri + "\">" + argsxml + "</r:" + method + "_INPUT></Body></Envelope>", callback, tag, pri);
}

// Perform a WSMAN ENUM operation
obj.ExecEnum = function ExecEnum(resuri, callback, tag, pri) {
obj.ExecEnum = function ExecEnum(resuri, callback, tag, pri)
{
obj.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/enumeration/Enumerate</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout></Header><Body><Enumerate xmlns=\"http://schemas.xmlsoap.org/ws/2004/09/enumeration\" /></Body></Envelope>", callback, tag, pri);
}

// Perform a WSMAN PULL operation
obj.ExecPull = function ExecPull(resuri, enumctx, callback, tag, pri) {
obj.ExecPull = function ExecPull(resuri, enumctx, callback, tag, pri)
{
obj.PerformAjax("http://schemas.xmlsoap.org/ws/2004/09/enumeration/Pull</a:Action><a:To>" + obj.Address + "</a:To><w:ResourceURI>" + resuri + "</w:ResourceURI><a:MessageID>" + (obj.NextMessageId++) + "</a:MessageID><a:ReplyTo><a:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</a:Address></a:ReplyTo><w:OperationTimeout>PT60S</w:OperationTimeout></Header><Body><Pull xmlns=\"http://schemas.xmlsoap.org/ws/2004/09/enumeration\"><EnumerationContext>" + enumctx + "</EnumerationContext><MaxElements>999</MaxElements><MaxCharacters>99999</MaxCharacters></Pull></Body></Envelope>", callback, tag, pri);
}

Expand Down