-
Notifications
You must be signed in to change notification settings - Fork 0
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
Create JavaScript file #12
base: master
Are you sure you want to change the base?
Changes from all commits
e69f216
2a84d9b
d6e2449
227873b
da61828
4293496
94cc7ab
340cba0
72e30ad
673b364
00ffc82
1c372d8
185e8ef
65410f1
0b9a9ef
47fb856
a61337b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,8 +32,10 @@ jobs: | |
|
||
- name: Install ESLint | ||
run: | | ||
npm install eslint@8.10.0 | ||
npm install eslint@9.18.0 | ||
npm install @microsoft/[email protected] | ||
npm install @eslint/[email protected] | ||
npm install [email protected] | ||
|
||
- name: Run ESLint | ||
env: | ||
|
@@ -43,8 +45,7 @@ jobs: | |
echo "Environment variables:" | ||
echo "ESLINT_USE_FLAT_CONFIG: $ESLINT_USE_FLAT_CONFIG" | ||
npx eslint . \ | ||
--config eslint.config.mjs \ | ||
--ext .js,.jsx,.ts,.tsx \ | ||
--config ./eslint.config.mjs \ | ||
--format @microsoft/eslint-formatter-sarif \ | ||
--output-file eslint-results.sarif | ||
continue-on-error: true | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import globals from "globals"; | ||
import pluginJs from "@eslint/js"; | ||
|
||
/** @type {import('eslint').Linter.Config[]} */ | ||
export default [ | ||
{ | ||
languageOptions: { | ||
globals: globals.browser, | ||
parserOptions: { | ||
ecmaVersion: 'latest', | ||
} | ||
}, | ||
rules: { | ||
'semi': ['error', 'always'], | ||
'no-unused-vars': 'warn', | ||
'eqeqeq': 'error', | ||
'space-before-function-paren': ['error', 'always'], | ||
'space-infix-ops': 'error' | ||
} | ||
}, | ||
pluginJs.configs.recommended, | ||
]; |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,85 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const moment = window.moment; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const _ = window._; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const $ = window.jQuery; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
const axios = window.axios; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
$(document).ready(function () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
var now = moment().format('MMMM Do YYYY, h:mm:ss a'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
$('#demo').text('Current time: ' + now); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
$('#greetButton').on('click', greetUser); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
$('#savePasswordButton').on('click', function() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Check failure Code scanning / ESLint Enforce consistent spacing before `function` definition opening parenthesis Error
Missing space before function parentheses.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
var username = $('#usernameInput').val(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
var password = $('#passwordInput').val(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
savePassword(username, password); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
export function greetUser () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Check warning Code scanning / CodeQL DOM text reinterpreted as HTML Medium DOM text Error loading related location Loading
Copilot Autofix AI about 1 month ago To fix this issue, we need to ensure that the user input is properly escaped before being inserted into the DOM. Instead of using
Suggested changeset
1
logic.js
Copilot is powered by AI and may make mistakes. Always verify output.
Refresh and try again.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
var name = document.getElementById('userInput').value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if (name == "") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -18,3 +18,3 @@ | ||
var name = document.getElementById('userInput').value; | ||
if (name == "") { | ||
if (name === "") { | ||
name = "guest"; |
Check failure
Code scanning / CodeQL
Clear text storage of sensitive information High
an access to password
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 1 month ago
To fix the problem, we need to ensure that the password is encrypted before being stored in localStorage. We can use the Node.js crypto
module to encrypt the password. This will involve creating an encryption function and using it to encrypt the password before storing it. Additionally, we should avoid displaying the password in clear text in the DOM.
-
Copy modified line R5 -
Copy modified lines R28-R30 -
Copy modified lines R36-R40
@@ -4,2 +4,3 @@ | ||
const axios = window.axios; | ||
const crypto = window.crypto || require('crypto'); | ||
|
||
@@ -26,4 +27,5 @@ | ||
if (_.isEmpty(username) || _.isEmpty(password)) return; | ||
localStorage.setItem(username, password); | ||
$('#demo').text('Username: ' + username + ', Password: ' + password); | ||
const encryptedPassword = encrypt(password); | ||
localStorage.setItem(username, encryptedPassword); | ||
$('#demo').text('Username: ' + username + ', Password: [encrypted]'); | ||
} | ||
@@ -33,2 +35,7 @@ | ||
} | ||
|
||
function encrypt(text) { | ||
const cipher = crypto.createCipher('aes-256-ctr', 'password'); | ||
return cipher.update(text, 'utf8', 'hex') + cipher.final('hex'); | ||
} | ||
|
Check failure
Code scanning / CodeQL
Hard-coded credentials Critical
Check warning
Code scanning / CodeQL
Inclusion of functionality from an untrusted source Medium