This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public async getPage() { | |
| if (!this.browser) { | |
| await this.initBrowser(); | |
| } | |
| const page = await this.browser.newPage(); | |
| // Avoiding Bot detection | |
| const userAgent = | |
| 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.39 Safari/537.36'; | |
| await page.setUserAgent(userAgent); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | private async initBrowser() { | |
| const browserArgs: PuppeteerLaunchOptions = { | |
| args: [ | |
| '--no-sandbox', | |
| '--disable-setuid-sandbox', | |
| '--headless', | |
| '--disable-gpu', | |
| '--disable-dev-shm-usage', | |
| '--disable-web-security', | |
| '--disable-infobars', | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import { EventEmitter } from 'events'; | |
| import * as Puppeteer from 'puppeteer'; | |
| export class HeadlessBrowser extends EventEmitter { | |
| protected browser: Puppeteer.Browser; | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | export default withAuthenticator(Swagger, true, [ | |
| <Greetings />, | |
| <Loading />, | |
| <SignIn />, | |
| <RequireNewPassword/>, | |
| <ForgotPassword />, | |
| ], | |
| ); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | const Swagger = ({...props}) => { | |
| useEffect(() => { | |
| const ui = SwaggerUI({ | |
| dom_id: '#swagger-custom-ui', | |
| spec: swaggerData, | |
| displayRequestDuration: true, | |
| syntaxHighlight: { | |
| activate: true, | |
| theme: 'monokai' | |
| }, | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | REACT_APP_REGION=us-east-1 | |
| REACT_APP_USER_POOL_ID=<value> | |
| REACT_APP_APP_CLIENT_ID=<client> | |
| REACT_APP_API_KEY=<Optional API key> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | YARN_AUDIT_SLACK_TOKEN=<yourToken> yarn run audit_report | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | private async sendSlackMessage(countVulnerabilities: number, packageName: string): Promise<void> { | |
| const postData = { | |
| attachments: [ | |
| { | |
| author_name: 'YARN - AUDIT', | |
| color: '#ff0000', | |
| mrkdwn_in: ['text', 'pretext'], | |
| text: `Found *${countVulnerabilities}* vulnerabilities in _${packageName}_ project, for more details run _yarn audit_`, | |
| }, | |
| ], | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | private calculateVulnerabilities(dataVulnerabilities: Vulnerabilities): number { | |
| const countVulnerabilities: number = Object.values( | |
| dataVulnerabilities, | |
| ).reduce((total: number, current: number) => { | |
| return total + current; | |
| }); | |
| return countVulnerabilities; | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | private filterSummaryData(vulnerabilities: string []): AuditData { | |
| const summary: string | undefined = | |
| vulnerabilities.find((item: string) => { | |
| const itemParsed: any = JSON.parse(item); | |
| return itemParsed.type === 'auditSummary'; | |
| }) || '{}'; | |
| const summaryData: any = JSON.parse(summary); | |
| return summaryData as AuditData; | |
| } |