- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.5k
 
Fix security issues reported by Dependabot for version 4 #5514
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
          
     Draft
      
      
            kretajak
  wants to merge
  3
  commits into
  webpack:version-4
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
kretajak:fix/security-issues
  
      
      
   
  
    
  
  
  
 
  
      
    base: version-4
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
      
        
          +503
        
        
          −46
        
        
          
        
      
    
  
  
     Draft
                    Changes from 2 commits
      Commits
    
    
            Show all changes
          
          
            3 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      
    File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| "use strict"; | ||
| 
     | 
||
| const webpack = require("webpack"); | ||
| const Server = require("../../lib/Server"); | ||
| const config = require("../fixtures/client-config/webpack.config"); | ||
| const runBrowser = require("../helpers/run-browser"); | ||
| const [port1, port2] = require("../ports-map")["cross-origin-request"]; | ||
| 
     | 
||
| describe("cross-origin requests", () => { | ||
| const devServerPort = port1; | ||
| const htmlServerPort = port2; | ||
| const htmlServerHost = "127.0.0.1"; | ||
| 
     | 
||
| it("should return 403 for cross-origin no-cors non-module script tag requests", async () => { | ||
| const compiler = webpack(config); | ||
| const devServerOptions = { | ||
| port: devServerPort, | ||
| allowedHosts: "auto", | ||
| }; | ||
| const server = new Server(devServerOptions, compiler); | ||
| 
     | 
||
| await server.start(); | ||
| 
     | 
||
| // Start a separate server for serving the HTML file | ||
| const http = require("http"); | ||
| const htmlServer = http.createServer((req, res) => { | ||
| res.writeHead(200, { "Content-Type": "text/html" }); | ||
| res.end(` | ||
| <html> | ||
| <head> | ||
| <script src="http://localhost:${devServerPort}/main.js"></script> | ||
| </head> | ||
| <body></body> | ||
| </html> | ||
| `); | ||
| }); | ||
| htmlServer.listen(htmlServerPort, htmlServerHost); | ||
| 
     | 
||
| const { page, browser } = await runBrowser(); | ||
| try { | ||
| const pageErrors = []; | ||
| 
     | 
||
| page.on("pageerror", (error) => { | ||
| pageErrors.push(error); | ||
| }); | ||
| 
     | 
||
| const scriptTagRequest = page.waitForResponse( | ||
| `http://localhost:${devServerPort}/main.js` | ||
| ); | ||
| 
     | 
||
| await page.goto(`http://${htmlServerHost}:${htmlServerPort}`); | ||
| 
     | 
||
| const response = await scriptTagRequest; | ||
| 
     | 
||
| expect(response.status()).toBe(403); | ||
| } catch (error) { | ||
| throw error; | ||
| } finally { | ||
| await browser.close(); | ||
| await server.stop(); | ||
| htmlServer.close(); | ||
| } | ||
| }); | ||
| 
     | 
||
| it("should return 200 for cross-origin cors non-module script tag requests", async () => { | ||
| const compiler = webpack(config); | ||
| const devServerOptions = { | ||
| port: devServerPort, | ||
| allowedHosts: "auto", | ||
| headers: { | ||
| "Access-Control-Allow-Origin": "*", | ||
| }, | ||
| }; | ||
| const server = new Server(devServerOptions, compiler); | ||
| 
     | 
||
| await server.start(); | ||
| 
     | 
||
| // Start a separate server for serving the HTML file | ||
| const http = require("http"); | ||
| const htmlServer = http.createServer((req, res) => { | ||
| res.writeHead(200, { "Content-Type": "text/html" }); | ||
| res.end(` | ||
| <html> | ||
| <head> | ||
| <script src="http://localhost:${devServerPort}/main.js" crossorigin></script> | ||
| </head> | ||
| <body></body> | ||
| </html> | ||
| `); | ||
| }); | ||
| htmlServer.listen(htmlServerPort, htmlServerHost); | ||
| 
     | 
||
| const { page, browser } = await runBrowser(); | ||
| try { | ||
| const pageErrors = []; | ||
| 
     | 
||
| page.on("pageerror", (error) => { | ||
| pageErrors.push(error); | ||
| }); | ||
| 
     | 
||
| const scriptTagRequest = page.waitForResponse( | ||
| `http://localhost:${devServerPort}/main.js` | ||
| ); | ||
| 
     | 
||
| await page.goto(`http://${htmlServerHost}:${htmlServerPort}`); | ||
| 
     | 
||
| const response = await scriptTagRequest; | ||
| 
     | 
||
| expect(response.status()).toBe(200); | ||
| } catch (error) { | ||
| throw error; | ||
| } finally { | ||
| await browser.close(); | ||
| await server.stop(); | ||
| htmlServer.close(); | ||
| } | ||
| }); | ||
| }); | 
  
    
      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
    
  
  
    
              
  
    
      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
    
  
  
    
              
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
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.
Recently we added some fixes here to skip check for
allowedHost, please add it hereUh oh!
There was an error while loading. Please reload this page.
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.
It seems not that straightforward. To me bigger effort is needed to incorporate changes from 03d1214. This PR uses functions defined in previous commits not available in line 4.
If it's not a problem, I would consider merging this PR and creating separate PR for task you mentioned.
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.
@kretajak let's include 03d1214 here, otherwise in some cases it will be impossible to setup a new version and we can merge
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.
@kretajak let me know if you need help backporting that commit. I could try to add it on top of your existing PR if you don't have time to. We have at least 3 Docusaurus issues asking us to solve this security warning so happy to help and get this solved asap.
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.
I'm currently trying to backport that commit. I'll inform you whether I was able to make it.
Uh oh!
There was an error while loading. Please reload this page.
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.
I have added new commit which should move us a bit closer. Seems like also changes from 6045b1e might be required as they are tightly connected to 03d1214.
@slorber feel free to continue the work.