Skip to content

autofix - #23

Merged
ruhdevops merged 14 commits into
alert-autofix-1from
main
Mar 9, 2026
Merged

ruhdevops merged 14 commits into
alert-autofix-1from
main

Conversation

@ruhdevops

Copy link
Copy Markdown
Owner

No description provided.

@ruhdevops ruhdevops self-assigned this Mar 9, 2026
@github-advanced-security

Copy link
Copy Markdown
Contributor

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.


async function downloadCert(host, port = 443, outputFile) {
return new Promise((resolve, reject) => {
const socket = tls.connect(port, host, { rejectUnauthorized: false }, () => {

Check failure

Code scanning / CodeQL

Disabling certificate validation High

Disabling certificate validation is strongly discouraged.

Copilot Autofix

AI 7 months ago

In general, the fix is to stop disabling certificate validation by removing rejectUnauthorized: false so that Node’s default (true) is used, or by explicitly setting rejectUnauthorized: true. If there is a need to connect to servers with custom or self‑signed certificates, that should be handled via a proper trust store (ca option) rather than disabling verification entirely.

For this specific file, the best fix that preserves existing functionality as much as possible while restoring security is:

  • Change the tls.connect call to use secure defaults by removing the third argument that disables verification and instead passing an options object that does not override rejectUnauthorized, or sets it explicitly to true.
  • Because the current call uses the 3‑argument form (port, host, options, callback), we can keep that shape and simply remove the rejectUnauthorized: false property, optionally replacing it with an empty options object or with other non‑dangerous options if needed later.

Concretely, in bin/checkScripts/downloadCert.js, on line 9, replace:

const socket = tls.connect(port, host, { rejectUnauthorized: false }, () => {

with a secure equivalent, such as:

const socket = tls.connect(port, host, {}, () => {

or:

const socket = tls.connect(port, host, { rejectUnauthorized: true }, () => {

No new methods, imports, or additional definitions are required; we only modify the arguments to tls.connect inside this function.


Suggested changeset 1
bin/checkScripts/downloadCert.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/bin/checkScripts/downloadCert.js b/bin/checkScripts/downloadCert.js
--- a/bin/checkScripts/downloadCert.js
+++ b/bin/checkScripts/downloadCert.js
@@ -6,7 +6,7 @@
 
 async function downloadCert(host, port = 443, outputFile) {
     return new Promise((resolve, reject) => {
-        const socket = tls.connect(port, host, { rejectUnauthorized: false }, () => {
+        const socket = tls.connect(port, host, {}, () => {
             const cert = socket.getPeerCertificate();
             if (!cert || !cert.raw) {
                 return reject(new Error('Unable to retrieve certificate.'));
EOF
@@ -6,7 +6,7 @@

async function downloadCert(host, port = 443, outputFile) {
return new Promise((resolve, reject) => {
const socket = tls.connect(port, host, { rejectUnauthorized: false }, () => {
const socket = tls.connect(port, host, {}, () => {
const cert = socket.getPeerCertificate();
if (!cert || !cert.raw) {
return reject(new Error('Unable to retrieve certificate.'));
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
// Function to download a TLS certificate from a host and save to a file
const fs = require('fs');
const tls = require('tls');
const net = require('net');

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused variable net.

Copilot Autofix

AI 7 months ago

Copilot could not generate an autofix suggestion

Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.

@ruhdevops
ruhdevops merged commit 7ed7134 into alert-autofix-1 Mar 9, 2026
5 of 9 checks passed
ruhdevops added a commit that referenced this pull request Mar 9, 2026
Merge pull request #23 from Ruh-Al-Tarikh/main

This branch was previously deployed

1 inactive deployment
github-pages — 229ed7ed Deployed Mar 9, 2026 by ruhdevops via deploy #12
Sign up for free to 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.

2 participants