opsgenie / opsgenie-nodejs-sdk Goto Github PK
View Code? Open in Web Editor NEWOpsGenie Node.js SDK
Home Page: https://www.opsgenie.com/docs/api-and-client-libraries/opsgenie-nodejs-api
License: Apache License 2.0
OpsGenie Node.js SDK
Home Page: https://www.opsgenie.com/docs/api-and-client-libraries/opsgenie-nodejs-api
License: Apache License 2.0
The requestretry
v1.13.0 has a cookie exposure vulnerability.
To reproduce:
$ npm audit
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ High │ Cookie exposure in requestretry │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package │ requestretry │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in │ >=7.0.0 │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ opsgenie-sdk │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path │ opsgenie-sdk > requestretry │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info │ https://github.com/advisories/GHSA-hjp8-2cm3-cc45 │
└───────────────┴──────────────────────────────────────────────────────────────┘
Environment:
Could you be able to update requestretry
to 7.0.0?
Currently, there are no types for typescript. Since most apps are using typescript these days please consider adding typings.
err.response_stringified = JSON.stringify(response);
^
TypeError: Cannot set property 'response_stringified' of null
at handleResponse (/mnt/Code/node_modules/opsgenie-sdk/lib/restApi.js:124:38)
at Request.<anonymous> (/mnt/Code/node_modules/opsgenie-sdk/lib/restApi.js:110:9)
at Request._callback (/mnt/Code/node_modules/opsgenie-sdk/node_modules/requestretry/node_modules/lodash/lodash.js:10067:25)
at Request.requestRetryReply [as reply] (/mnt/Code/node_modules/opsgenie-sdk/node_modules/requestretry/index.js:105:19)
at Request.<anonymous> (/mnt/Code/node_modules/opsgenie-sdk/node_modules/requestretry/index.js:133:10)
at Request.self.callback (/mnt/Code/node_modules/request/request.js:188:22)
at Request.emit (events.js:110:17)
at Request.<anonymous> (/mnt/Code/node_modules/request/request.js:1171:10)
at Request.emit (events.js:107:17)
at IncomingMessage.<anonymous> (/mnt/Code/node_modules/request/request.js:1091:12)
at IncomingMessage.g (events.js:199:16)
at IncomingMessage.emit (events.js:129:20)
at _stream_readable.js:908:16
at process._tickCallback (node.js:355:11)
The error is in this part:
if (response.statusCode < 200 || response.statusCode >= 300) {
if (process.env.NODE_ENV === 'development') {
err.response_stringified = JSON.stringify(response);
}```
Latest version available on npm is 0.4.5 but I could see in the issues that some fixes are done under 0.4.7
I am on Node 8.9.4. I have received the following error:
Cannot find module '../package' from 'configure.js'
I believe the issue is related to trying to require package
without the .json
extension. When I changed require('../package')
to require('../package.json')
in lib/configure.js
the issue was resolved.
Might be related to the newer version of Node.
.travis.yml exists but Travis CI is not active.
I've run npm test
on my local machine, it aborted due to jshint warnings.
Hi.
there is a vulnerability in request
package which is a peer dependency for requestretry
. request
is officially deprecated and has vulnerabilities https://www.npmjs.com/package/request
Unfortunately the maintainers of requestretry
most likely won't fix the issue (issue FGRibreau/node-request-retry#149 )
Do you have plans to replace requestretry
with another library or to fix the vulnerability in any other way?
var opsgenie = require('opsgenie-sdk')
opsgenie.configure({
api_key: ''
})
async function main() {
const a = await opsgenie.user.list({})
console.log(a)
}
main()
undefined
undefined:1
No handler found for url /v1/json/user/
^
SyntaxError: Unexpected token N in JSON at position 0
at JSON.parse ()
When a create
request is made the result contains also the newly created alertId
:
{
"took": 84,
"code": 200,
"alertId": "8faa119e-3d24-4878-abba-c69d7fee8c8b",
"message": "alert created",
"status": "successful",
"httpStatusCode": 200
}
It would be very practical if other operations as well would return the alertId
. For example the close
operation, where one can close alerts based on an alias
as well (and hence not having the alertId
). Currently the close
operation returns:
POST /v1/json/alert/close
{
"alias": "myalias"
}
{
"took": 54,
"code": 200,
"status": "successful",
"httpStatusCode": 2
}
Here, the alertID
would avoid us doing an extra request to get
the alert with the given alias
.
For the delete
operation this might not make much sense from the OpsGenie point of view. But when correlating these alert IDs with external systems, it would be nice to always return the ID.
(I know this is an extension that should be added to the underlying WebAPI)
opsgenie.configure({
retryDelay: 3, // <--- doesn't change anything
});
const createAlertRequest = {...};
opsgenie.alertV2.create(createAlertRequest, (requestStatus) => {
this.logger.info(`Created Opsgenie alert`, requestStatus, createAlertRequest);
const requestId = requestStatus?.requestId;
resolve({ requestId });
});
will still use the default 5s delay
It would be great if we could use this SDK with Typescript via a @types/opsgenie-sdk npm package
For example, the following params causes a 500 error to be returned from the server:
var activeAlertsParams = {
query: 'status != closed createdAt >=151003410.486',
offset: 0,
limit: 1,
sort: 'alias',
order: 'desc'
}
...while the following works fine:
var activeAlertsParams = {
query: 'status != closed createdAt >=151003410',
offset: 0,
limit: 1,
sort: 'alias',
order: 'desc'
}
I would expect a 422 / 400 status code in this case, not a 500.
The badge on README.md shows only dependencies. devDependencies is outdated.
Also, Greenkeeper is a great tool for automatic dependency updates and free for open source projects.
Per the docs: https://docs.opsgenie.com/docs/incident-api#add-detailscustom-properties-to-incident there should be support for adding/removing custom properties on incidents, but this is not currently implemented in the api. It looks like there is support on the Incident object, but the API returns a "No handler found" if you try to use the endpoint in the docs.
Hi team, is this project still alive and supported by OpsGenie?
The following code prints: "string"
opsgenie.alertV2.list(activeAlertsParams, function (error, alerts) {
if(!error) console.log(typeof(alerts))
}
This is mildly annoying because, in order to reference any properties on alerts
, I have to manually call JSON.parse(alerts)
myself
Shouldn't the callback be called with the result obtained from JSON.parse(...)
instead of just passing the raw response string to the callback?
EDIT: also, my package.json includes this version of the SDK - "opsgenie-sdk": "^0.4.1"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.