Skip to content

Port changes from commit bbc5570 - Update vulnerable dependencies and modernize deprecated API usage - #513

Merged
Tarun Ramsinghani (tarunramsinghani) merged 5 commits into
masterfrom
copilot/port-changes-from-bbc5570
Oct 3, 2025
Merged

Port changes from commit bbc5570 - Update vulnerable dependencies and modernize deprecated API usage#513
Tarun Ramsinghani (tarunramsinghani) merged 5 commits into
masterfrom
copilot/port-changes-from-bbc5570

Conversation

CopilotAI commented Oct 3, 2025

Copy link
Copy Markdown
Contributor

This PR ports changes from commit bbc5570070f792568d97eedcf5d1b6e0502cad21 which updates vulnerable dependencies and modernizes deprecated Node.js API usage.

🔒 Security & Dependency Updates

Updated the following packages to address security vulnerabilities and improve compatibility:

PackageOld VersionNew Version
archiver2.0.37.0.1
glob7.1.211.0.3
shelljs0.8.50.10.0
uuid3.0.113.0.0

Also removed unnecessary type definition packages (@types/glob, @types/uuid) as they are now included in their respective packages.

🔄 Code Modernization

UUID Import Modernization

Updated from deprecated CommonJS-style uuid usage to modern ES6 imports:

// Beforeimportuuid= require("uuid");def.id=uuid.v1();// Afterimport{v1asuuidv1}from"uuid";def.id=uuidv1();

URL Parsing Modernization

Replaced deprecated Node.js url.parse() with the modern URL constructor API:

// Beforeimporturl= require("url");this.parsedUrl=url.parse(this.serviceUrl);constsplitPath=this.parsedUrl.path.split("/");// Afterthis.parsedUrl=newURL(this.serviceUrl);constsplitPath=this.parsedUrl.pathname.split("/");

Added error handling to maintain backward compatibility with invalid URLs that the old url.parse() would accept.

Glob API Update

Updated from callback-based glob API to promise-based API:

// Beforeconstpromises=globs.map(pattern=>newPromise<string[]>((resolve,reject)=>{glob(pattern,(err,matches)=>{if(err)reject(err);elseresolve(matches);});}));// Afterconstpromises=globs.map(pattern=>glob(pattern));

TypeScript Configuration

Updated TypeScript compilation target from ES2018 to ES2019 to support newer JavaScript features.

✅ Validation

  • All updated dependencies validated against GitHub Advisory Database - No vulnerabilities found
  • CodeQL security scan completed - No alerts
  • Code review completed - No issues found
  • Changes maintain backward compatibility

📝 Additional Changes

  • Fixed indentation in package.json scripts section (standardized to 4-space indentation)
  • Cleaned up trailing whitespace in test files
  • Updated package-lock.json with all transitive dependency updates
  • Version bump: Updated package version from 0.22.1 to 0.22.2

Files modified: 8 files (package.json, package-lock.json, tsconfig.json, app/exec/build/tasks/create.ts, app/exec/extension/_lib/merger.ts, app/lib/connection.ts, tests/mock-server/utils/RequestParser.ts, tests/build-server-integration-tests.ts)

Original prompt

Port changes from bbc5570 commit from forked repo into the main repo @ @microsoft/tfs-cli. The PR should be created in the main repo and the changes from coomit to be ported over that PR


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

CopilotAIand others added 2 commits October 3, 2025 07:33
…nize URL parsing
Co-authored-by: tarunramsinghani <2929463+tarunramsinghani@users.noreply.github.com>
Co-authored-by: tarunramsinghani <2929463+tarunramsinghani@users.noreply.github.com>
CopilotAI changed the title [WIP] Port changes from commit bbc5570 to main repoPort changes from commit bbc5570 - Update vulnerable dependencies and modernize deprecated API usageOct 3, 2025
@tarunramsinghani

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@tarunramsinghani

Copy link
Copy Markdown
Contributor

Copilot update the patch version in the package.json

Co-authored-by: tarunramsinghani <2929463+tarunramsinghani@users.noreply.github.com>

CopilotAI commented Oct 3, 2025

Copy link
Copy Markdown
ContributorAuthor

Copilot update the patch version in the package.json

Updated the patch version from 0.22.1 to 0.22.2 in both package.json and package-lock.json (commit 8aca3fe)

- Revert mocha from 11.7.3 to 10.2.0 for better Node.js compatibility
- Revert rimraf from 6.0.1 to 2.6.1 to maintain backward compatibility
- Update Node.js engine requirement to >=16.0.0 for modern API support
- Improve error handling in server integration tests
- All tests passing with updated dependency versions
@tarunramsinghani

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@tarunramsinghani
Tarun Ramsinghani (tarunramsinghani) merged commit ae8b325 into masterOct 3, 2025
7 checks passed
@tarunramsinghani
Tarun Ramsinghani (tarunramsinghani) deleted the copilot/port-changes-from-bbc5570 branch October 3, 2025 11:49

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be more-thorough in our review of Copilot-authored code.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changed the pattern of the codebase, for no reason.

});
}),
);
const promises = globs.map(pattern => glob(pattern));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good change because of upstream API change.

Comment threadapp/lib/connection.ts
Comment on lines +14 to +28
// Parse URL, but handle failures gracefully to mimic url.parse() behavior
try {
this.parsedUrl = new URL(this.serviceUrl);
} catch (error) {
// Mimic url.parse() behavior for invalid URLs
// url.parse() would return an object with null/empty values instead of throwing
this.parsedUrl = {
protocol: this.serviceUrl && this.serviceUrl.includes('://') ? this.serviceUrl.split('://')[0] + ':' : '',
host: null,
hostname: null,
pathname: this.serviceUrl && !this.serviceUrl.includes('://') ? this.serviceUrl : '',
search: '',
hash: ''
} as any;
}

@nathanhammondNathan Hammond (nathanhammond)Oct 31, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method already has error handling and throws. If a user submits an invalid URL like /tfs/orgName we can just throw earlier, with a humanized version of that message. No need to limp it through only to fail it later.

Throwing earlier also fixes a bug on line 35 because of a poorly-ordered if clause.

URL input: /tfs/orgName

31: this.accountUrl = this.parsedUrl.protocol + "//" + this.parsedUrl.host; => null//null
35: this.accountUrl += "/" + "tfs"; => null//null/tfs

Comment threadapp/lib/connection.ts
Comment on lines +14 to +28
// Parse URL, but handle failures gracefully to mimic url.parse() behavior
try {
this.parsedUrl = new URL(this.serviceUrl);
} catch (error) {
// Mimic url.parse() behavior for invalid URLs
// url.parse() would return an object with null/empty values instead of throwing
this.parsedUrl = {
protocol: this.serviceUrl && this.serviceUrl.includes('://') ? this.serviceUrl.split('://')[0] + ':' : '',
host: null,
hostname: null,
pathname: this.serviceUrl && !this.serviceUrl.includes('://') ? this.serviceUrl : '',
search: '',
hash: ''
} as any;
}

@nathanhammondNathan Hammond (nathanhammond)Oct 31, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Parse URL, but handle failures gracefully to mimic url.parse() behavior
try{
this.parsedUrl=newURL(this.serviceUrl);
}catch(error){
// Mimic url.parse() behavior for invalid URLs
// url.parse() would return an object with null/empty values instead of throwing
this.parsedUrl={
protocol: this.serviceUrl&&this.serviceUrl.includes('://') ? this.serviceUrl.split('://')[0]+':' : '',
host: null,
hostname: null,
pathname: this.serviceUrl&&!this.serviceUrl.includes('://') ? this.serviceUrl : '',
search: '',
hash: ''
}asany;
}
try{
this.parsedUrl=newURL(this.serviceUrl);
}catch(error){
if(error.code==='ERR_INVALID_URL'){
thrownewError('Please enter a fully-qualified URL.')
}else{
throwerror;
}
}

Comment on lines +16 to +20
// Parse query parameters using forEach (guaranteed to be available)
const query: { [key: string]: string } = {};
parsedUrl.searchParams.forEach((value, key) => {
query[key] = value;
});

@nathanhammondNathan Hammond (nathanhammond)Oct 31, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Parse query parameters using forEach (guaranteed to be available)
constquery: {[key: string]: string}={};
parsedUrl.searchParams.forEach((value,key)=>{
query[key]=value;
});
constquery=Object.fromEntries(parsedUrl.searchParams.entries());

Nathan Hammond (nathanhammond) pushed a commit to nathanhammond/tfs-cli that referenced this pull request Oct 31, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@tarunramsinghani@nathanhammond@sanjuyadav24