Skip to content

Commit 8bea38f

Browse files
vaibhavbhalla2505Vaibhav  Bhallayeshamavani
authored
feat(ci-cd): add trivy scan (#240)
add trivy scan and fix sonarqube issues GH-239 Co-authored-by: Vaibhav Bhalla <vaibhav.bhalla@SFSupports-MacBook-Air.local> Co-authored-by: yeshamavani <83634146+yeshamavani@users.noreply.github.com>
1 parent 7490e06 commit 8bea38f

File tree

5 files changed

+58
-26
lines changed

5 files changed

+58
-26
lines changed

.github/workflows/trivy.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: Trivy Scan
4+
5+
# Controls when the action will run. Triggers the workflow on push or pull request
6+
# events but only for the master branch
7+
on:
8+
pull_request:
9+
branches: [master]
10+
types: [opened, synchronize, reopened]
11+
12+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
13+
jobs:
14+
# This workflow contains a single job called "trivy"
15+
trivy:
16+
# The type of runner that the job will run on
17+
runs-on: [self-hosted, linux, codebuild]
18+
19+
# Steps represent a sequence of tasks that will be executed as part of the job
20+
steps:
21+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
22+
- uses: actions/checkout@v3
23+
24+
- name: Run Trivy vulnerability scanner in repo mode
25+
uses: aquasecurity/trivy-action@0.28.0
26+
with:
27+
scan-type: "fs"
28+
scan-ref: "${{ github.workspace }}"
29+
trivy-config: "${{ github.workspace }}/trivy.yml"

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
<a href="https://sonarcloud.io/summary/new_code?id=sourcefuse_loopback4-notifications" target="_blank">
1010
<img alt="Sonar Quality Gate" src="https://img.shields.io/sonar/quality_gate/sourcefuse_loopback4-notifications?server=https%3A%2F%2Fsonarcloud.io">
1111
</a>
12-
<a href="https://app.snyk.io/org/ashishkaushik/reporting?context[page]=issues-detail&project_target=%255B%2522sourcefuse%252Floopback4-notifications%2522%255D&project_origin=%255B%2522github%2522%255D&issue_status=%255B%2522Open%2522%255D&issue_by=Severity&table_issues_detail_cols=SCORE%257CCVE%257CCWE%257CPROJECT%257CEXPLOIT%2520MATURITY%257CAUTO%2520FIXABLE%257CINTRODUCED%257CSNYK%2520PRODUCT&v=1">
13-
<img alt="Synk Status" src="https://img.shields.io/badge/SYNK_SECURITY-MONITORED-GREEN">
14-
</a>
1512
<a href="https://github.com/sourcefuse/loopback4-notifications/graphs/contributors" target="_blank">
1613
<img alt="GitHub contributors" src="https://img.shields.io/github/contributors/sourcefuse/loopback4-notifications">
1714
</a>

src/providers/push/pubnub/pubnub.provider.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,11 @@ export class PubNubProvider implements Provider<PubNubNotification> {
2323

2424
pubnubService: Pubnub;
2525
getGeneralMessageObject(message: PubNubMessage) {
26-
const commonDataNotification: MessageConfig = Object.assign(
27-
{
28-
title: message.subject ?? '',
29-
description: message.body,
30-
body: message.body,
31-
},
32-
message.options,
33-
);
26+
const commonDataNotification: MessageConfig = {
27+
title: message.subject ?? '',
28+
description: message.body,
29+
...message.options,
30+
};
3431
const pnFcm = {
3532
data: {
3633
...commonDataNotification,

src/providers/sms/twilio/twilio.provider.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,19 @@ export class TwilioProvider implements Provider<TwilioNotification> {
3939
}
4040
const publishes = message.receiver.to.map(async receiver => {
4141
const msg: string = message.body;
42+
const isSMS: boolean =
43+
receiver.type === TwilioSubscriberType.TextSMSUser;
4244
const twilioMsgObj: TwilioCreateMessageParams = {
4345
body: msg,
44-
from:
45-
receiver.type &&
46-
receiver.type === TwilioSubscriberType.TextSMSUser
47-
? String(this.twilioConfig?.smsFrom)
48-
: String(this.twilioConfig?.waFrom),
49-
to:
50-
receiver.type &&
51-
receiver.type === TwilioSubscriberType.TextSMSUser
52-
? `+${receiver.id}`
53-
: `whatsapp:+${receiver.id}`,
46+
from: isSMS
47+
? String(this.twilioConfig?.smsFrom)
48+
: String(this.twilioConfig?.waFrom),
49+
to: isSMS ? `+${receiver.id}` : `whatsapp:+${receiver.id}`,
50+
mediaUrl: message.mediaUrl,
5451
};
5552

5653
// eslint-disable-next-line no-unused-expressions
57-
message.mediaUrl && (twilioMsgObj.mediaUrl = message.mediaUrl);
58-
59-
// eslint-disable-next-line no-unused-expressions
60-
receiver.type &&
61-
receiver.type === TwilioSubscriberType.TextSMSUser &&
54+
isSMS &&
6255
this.twilioConfig?.smsStatusCallback &&
6356
(twilioMsgObj.statusCallback =
6457
this.twilioConfig?.smsStatusCallback);

trivy.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
format: table
2+
exit-code: 1
3+
severity:
4+
- HIGH
5+
- CRITICAL
6+
skip-files:
7+
- db.env
8+
security-checks:
9+
- vuln
10+
- secret
11+
- license
12+
vulnerability:
13+
type:
14+
- os
15+
- library
16+
ignore-unfixed: true

0 commit comments

Comments
 (0)