File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 66
77const fs = require ( 'node:fs' ) ;
88const path = require ( 'node:path' ) ;
9+ const { URL } = require ( 'node:url' ) ;
910const { glob } = require ( 'glob' ) ;
1011
1112// Version constants
@@ -20,11 +21,17 @@ const MASTER_INDEX_VERSION = '0.1.0';
2021 * @returns {Promise<object|null> } Repository metadata or null if not available
2122 */
2223async function fetchGitHubMetadata ( repoUrl ) {
23- if ( ! repoUrl ?. includes ( 'github.com' ) ) {
24+ if ( ! repoUrl ) {
2425 return null ;
2526 }
2627
2728 try {
29+ // Parse and validate the URL to prevent substring injection attacks
30+ const url = new URL ( repoUrl ) ;
31+ if ( url . hostname !== 'github.com' ) {
32+ return null ;
33+ }
34+
2835 // Extract owner/repo from URL
2936 const match = new RegExp ( / g i t h u b \. c o m \/ ( [ ^ / ] + ) \/ ( [ ^ / ] + ) / ) . exec ( repoUrl ) ;
3037 if ( ! match ) {
You can’t perform that action at this time.
0 commit comments