Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Extending botsito
is pretty straight forward. Within the scripts/students
directory, create a new file. In the file, declare a named function. Let's use a
for the purposes of example.
function a() {
}
In order to interact with botsito
, our function will receive it as a parameter.
function a(botsito) {
}
Having botsito
within our function scope allows us to interact with it. The following methods are available:
botsito.logger.info
Logs to the console. Helpful for debugging.
Takes in a single parameter. The value of what is gonna be logged.
Returns undefined
.
function a(botsito) {
botsito.logger.info('function "a" is being loaded');
}
botsito.logger.error
Logs to the console. It's used when we want to inform ourselves that something went wrong.
Takes in a single parameter. The value of what is gonna be logged.
Returns undefined
.
function a(botsito) {
botsito.logger.error(new Error('omg something went wrong'));
}
botsito.brain.get
Looks for a previously stored value in botsito
.
It takes a single parameter.
The key
used to fetch the value;
Returns the value previously stored.
function a(botsito) {
var b = botsito.brain.get('my key');
if (!b) {
return botsito.logger.error(new Error('b is undefined!'));
}
}
botsito.brain.set
Stores a value within botsito
.
Takes two parameters.
First parameter is the key
for which you will look for it later via botsito.brain.get
.
The second parameter is the value you wish botsito
to store.
function a(botsito) {
botsito.brain.set('my key', 'my valueeee');
var b = botsito.brain.get('my key');
if (!b) {
return botsito.logger.error(new Error('b is undefined!'));
}
botsito.logger.info(b);
}
botsito.listen
Interface in which botsito
receives messages and acts upon them.
Takes two parameters. Both are functions.
First parameter function receives a single parameter called msg
. It holds properties like text
(the message posted) and user
(the poster of the message). In this function you will determine if you will act upon the msg
received. This function must return true
or false
.
Second parameter function receives a single parameter called response
. It holds the method reply
which allows us to write to the channel. This is where you will put the bulk of your logic will live. This function will only be called if the first parameter function returned true
.
function a(botsito) {
function validator(msg) {
var willReply = false;
if (msg.text.indexOf('pi time') !== -1) {
willReply = true;
}
return willReply;
}
function postBack(response) {
return response.reply('PI TIMEEEEE');
}
botsito.listen(validator, postBack);
}
This function will listen for messages that include the phrase pi time
and will reply with PI TIMEEEEE
to the channel.
The response
object also contains additional information inside the envelope
property. Try logging this property out to see what you learn.
Once you are satisfied with your function, we need to make it readable. To do so, add the following line at the end of your file:
module.exports = a;
That's it! Now your function is ready to join botsito
.
FAQs
Mentor bot
The npm package botsito receives a total of 0 weekly downloads. As such, botsito popularity was classified as not popular.
We found that botsito demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.