-
Notifications
You must be signed in to change notification settings - Fork 0
fix(MESHAGEN-006-2): CU-86akhf8u3 2 review findings in amt-wsman.js #130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) { | ||
| 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; } | ||
|
|
@@ -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) { | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 🤖 Prompt for AI agentsfix 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>'; } | ||
|
|
@@ -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); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
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 ofWsmanStackCreateService. Only the brace placement was changed; the function body is untouched.🤖 Prompt for AI agents
fix confidence: 🟡 60 medium — react 👍/👎 to teach the reviewer