Git Product home page Git Product logo

madrid's Introduction

Web page similar to keycode.info

Netlify Status

GitHub Actions Status

You can use the running version of this project at https://polatengin-madrid.netlify.com/

The reason I made this project;

Technologies I used in this project are;

  • Typescript
  • WebPack
    • PostCSS
  • GitHub Actions
  • Docker
  • Netlify
  • DevContainers

To create the project, let's run the following command in an empty directory

npm init --force

Now, open a Terminal window and run the following command to add the keycode npm package to package.json

npm i keycode --save

Now, we can require the keycode module in src/index.ts

const keycode = require('keycode');

By attaching to the keydown event of the window global object, we can capture all the pressed keys in the entire browser window.

window.addEventListener('keydown', (e) => {
});

By calling the stopPropagation() and preventDefault() methods in the event handler, we prevent the keys from being processed by the browser.

var index = document.createElement('li');
index.innerHTML = `${currentIndex}`;

var key = document.createElement('li');
key.innerHTML = keycode(e);

var keyCode = document.createElement('li');
keyCode.innerHTML = `${e.keyCode}`;

var shift = document.createElement('li');
shift.innerHTML = e.shiftKey ? '✓' : '⨯';

var control = document.createElement('li');
control.innerHTML = e.ctrlKey ? '✓' : '⨯';

var alt = document.createElement('li');
alt.innerHTML = e.altKey ? '✓' : '⨯';

var item = document.createElement('ul');
item.appendChild(index);
item.appendChild(key);
item.appendChild(keyCode);
item.appendChild(shift);
item.appendChild(control);
item.appendChild(alt);

article.insertAdjacentElement('afterbegin', item);

So, even if the keys like F5, F12 are pressed, the browser will not process them.

We add the required html code into the ./src/index.html file so that a table will appear on the screen.

<main class="row title">
  <ul>
    <li>#</li>
    <li>Key</li>
    <li>Key Code</li>
    <li>Shift</li>
    <li>Control</li>
    <li>Alt</li>
  </ul>
</main>
<article class="row item">
</article>

Also, we're providing the same editor settings to the developers (space/tab, end-of-line-character, etc.) with the .editorconfig file.

In the tsconfig.json file, we give the compilerOptions.outDir property value of ./dist, so that when the webpack compiles, the compiled files will be created in the ./dist folder.

In the ./src/index.ts file, we capture all keydown events via the window.addEventListener() method.

We use the following two lines to prevent any keydown events we capture from being captured by the browser.

e.stopPropagation();
e.preventDefault();

We added the following plugins into the webpack.config.js file

Also, with the hash option of the HtmlWebpackPlugin plugin, we added the compiled ts files into the index.html as bundle.js?{HASH}.

Thanks to Multi-Layered Dockerfile, we compile the project in node:13.10.1-buster image, then move all compiled files to nginx:1.17.0-alpine image and expose them.

At the end, we have a Docker Image that takes about 20MB in size.

Sample Screenshot

madrid's People

Contributors

mend-bolt-for-github[bot] avatar polatengin avatar

Watchers

 avatar  avatar

madrid's Issues

WS-2020-0068 (High) detected in yargs-parser-13.1.2.tgz

WS-2020-0068 - High Severity Vulnerability

Vulnerable Library - yargs-parser-13.1.2.tgz

the mighty option parser used by yargs

Library home page: https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.2.tgz

Path to dependency file: /tmp/ws-scm/madrid/package.json

Path to vulnerable library: /tmp/ws-scm/madrid/node_modules/webpack-cli/node_modules/yargs-parser/package.json

Dependency Hierarchy:

  • webpack-cli-3.3.11.tgz (Root Library)
    • yargs-13.2.4.tgz
      • yargs-parser-13.1.2.tgz (Vulnerable Library)

Found in HEAD commit: eb25f033fc29d76bfac04b3fffcf4b3ae6db37d4

Vulnerability Details

Affected versions of yargs-parser are vulnerable to prototype pollution. Arguments are not properly sanitized, allowing an attacker to modify the prototype of Object, causing the addition or modification of an existing property that will exist on all objects. Parsing the argument --foo.proto.bar baz' adds a bar property with value baz to all objects. This is only exploitable if attackers have control over the arguments being passed to yargs-parser.

Publish Date: 2020-05-01

URL: WS-2020-0068

CVSS 3 Score Details (7.5)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Adjacent
    • Attack Complexity: High
    • Privileges Required: None
    • User Interaction: None
    • Scope: Unchanged
  • Impact Metrics:
    • Confidentiality Impact: High
    • Integrity Impact: High
    • Availability Impact: High

For more information on CVSS3 Scores, click here.

Suggested Fix

Type: Upgrade version

Origin: https://www.npmjs.com/package/yargs-parser

Release Date: 2020-05-04

Fix Resolution: https://www.npmjs.com/package/yargs-parser/v/18.1.2,https://www.npmjs.com/package/yargs-parser/v/15.0.1


Step up your Open Source Security Game with WhiteSource here

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.