Ausnahme gefangen: SSL certificate problem: certificate is not yet valid ๐Ÿ“Œ Lessons from open-source: Algorithm used to compute error.digest in Next.js

๐Ÿ  Team IT Security News

TSecurity.de ist eine Online-Plattform, die sich auf die Bereitstellung von Informationen,alle 15 Minuten neuste Nachrichten, Bildungsressourcen und Dienstleistungen rund um das Thema IT-Sicherheit spezialisiert hat.
Ob es sich um aktuelle Nachrichten, Fachartikel, Blogbeitrรคge, Webinare, Tutorials, oder Tipps & Tricks handelt, TSecurity.de bietet seinen Nutzern einen umfassenden รœberblick รผber die wichtigsten Aspekte der IT-Sicherheit in einer sich stรคndig verรคndernden digitalen Welt.

16.12.2023 - TIP: Wer den Cookie Consent Banner akzeptiert, kann z.B. von Englisch nach Deutsch รผbersetzen, erst Englisch auswรคhlen dann wieder Deutsch!

Google Android Playstore Download Button fรผr Team IT Security



๐Ÿ“š Lessons from open-source: Algorithm used to compute error.digest in Next.js


๐Ÿ’ก Newskategorie: Programmierung
๐Ÿ”— Quelle: dev.to

This lesson is picked Next.js source code. In this article, you will learn how error.digest is computed in Next.js.

Error.digest

The docs says โ€œAn automatically generated hash of the error thrown in a Server Component. It can be used to match the corresponding error in server-side logs.โ€

You match this digest on your server logs. Next.js shows only the digest to prevent sensitive information leaked to the client side.

Do check the following Stackoverflow questions:

  1. Next.js error in production mode โ€” Digest: 1782794309
  2. https://stackoverflow.com/questions/76713709/what-is-a-digest-property

Letโ€™s find out how Next.js automatically generates this hash for an error.

error.digest

As you can see from the above code snippet, it uses a function named stringHash which is imported at the top of create-error-handler.tsx

Practice the exercises based on documentation to become an expert in Next.js.

import stringHash from 'next/dist/compiled/string-hash'

Next.js has a quite some packages bundled in a folder named compiled. string-hash is an npm package.

I checked the string-hash source code.

"use strict";

function hash(str) {
  var hash = 5381,
      i    = str.length;

  while(i) {
    hash = (hash \* 33) ^ str.charCodeAt(--i);
  }

  /\* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
   \* integers. Since we want the results to be always positive, convert the
   \* signed int to an unsigned by doing an unsigned bitshift. \*/
  return hash >>> 0;
}

module.exports = hash;

The particular algorithm is quite similar to djb2, by Dan Bernstein and is available here.

It has 1.7M downloads per week on NPM. I wish, some day I write some library that gets this many downloads.

Conclusion

This is what Next.js docs say about error.digest โ€” โ€œAn automatically generated hash of the error thrown in a Server Component. It can be used to match the corresponding error in server-side logsโ€.

I looked at the source code to find out that string-hash algorithm is used to automatically generate a hash like below:

err.digest = stringHash(
  err.message + (errorInfo?.stack || err.stack || '')
).toString()

Further digging led me to discover that string-hash has about 17 lines of code with 1.7 million downloads per week on NPM. I wish, some day I write some library that gets this many downloads. I did write few npm packages that are not so popular.

...



๐Ÿ“Œ OpenStack Compute 13.0.0 Compute Nodes Handler Disk Consumption Denial of Service


๐Ÿ“ˆ 26.17 Punkte

๐Ÿ“Œ OpenStack Compute 13.0.0 Compute Nodes Handler Disk Consumption Denial of Service


๐Ÿ“ˆ 26.17 Punkte

๐Ÿ“Œ Yo dawg, I heard you like computing, so I put a computer in your computer so you can compute while you compute.


๐Ÿ“ˆ 26.17 Punkte

๐Ÿ“Œ Intel: Auf die Compute Card folgt das Compute Module


๐Ÿ“ˆ 26.17 Punkte

๐Ÿ“Œ Intel: Auf die Compute Card folgt das Compute Module


๐Ÿ“ˆ 26.17 Punkte

๐Ÿ“Œ Intel Mini-PC: Auf die Compute Card folgt das NUC Compute Element


๐Ÿ“ˆ 26.17 Punkte

๐Ÿ“Œ Microsoft Windows Host Compute Host Compute Service Shim Code Execution memory corruption


๐Ÿ“ˆ 26.17 Punkte

๐Ÿ“Œ What is an Algorithm? Algorithm Definition for Computer Science Beginners


๐Ÿ“ˆ 26 Punkte

๐Ÿ“Œ How to Fix Error 3, Error 7, and Error 60 in Microsoft Edge for Windows 10


๐Ÿ“ˆ 20.9 Punkte

๐Ÿ“Œ Nutella Used An Algorithm To Design 7 Million Unique Labels


๐Ÿ“ˆ 20.59 Punkte

๐Ÿ“Œ Microcode Decryptor: recovered format of microcode updates, algorithm and the encryption key used to protect the microcode for Intel CPUs


๐Ÿ“ˆ 20.59 Punkte

๐Ÿ“Œ Goodbye SHA-1: NIST Retires 27-Year-Old Widely Used Cryptographic Algorithm


๐Ÿ“ˆ 20.59 Punkte

๐Ÿ“Œ Researchers Find Flaws in Algorithm Used To Identify Atypical Medication Orders


๐Ÿ“ˆ 20.59 Punkte

๐Ÿ“Œ Court Rules Deliveroo Used 'Discriminatory' Algorithm


๐Ÿ“ˆ 20.59 Punkte

๐Ÿ“Œ Need help to find out what algorithm / key was used


๐Ÿ“ˆ 20.59 Punkte

๐Ÿ“Œ This paper used algorithm to find copypaste bug in Linux, what is the bug?


๐Ÿ“ˆ 20.59 Punkte

๐Ÿ“Œ Astronomers at Caltech Have Used a Machine Learning Algorithm to Classify 1,000 Supernovae Completely Autonomously


๐Ÿ“ˆ 20.59 Punkte

๐Ÿ“Œ Microsoft to ship upgraded Surface Hub 2 compute cartridge next year


๐Ÿ“ˆ 19.42 Punkte

๐Ÿ“Œ HPE unveils next-generation compute to power hybrid environments and digital transformation


๐Ÿ“ˆ 19.42 Punkte

๐Ÿ“Œ Accelerating the Next Era of Compute Starts with Intel | Intel


๐Ÿ“ˆ 19.42 Punkte

๐Ÿ“Œ PHP Now Supports Argon2 Next-Generation Password Hashing Algorithm


๐Ÿ“ˆ 19.34 Punkte

๐Ÿ“Œ What's next for encryption if the RSA algorithm is broken?


๐Ÿ“ˆ 19.34 Punkte

๐Ÿ“Œ Unlock Next-Level Authentication in Next.js with Next Auth and TypeScript Module Augmentation


๐Ÿ“ˆ 19.01 Punkte

๐Ÿ“Œ CVE-2023-45886 | F5 BIG-IP/BIG-IP Next/BIG-IP Next SPK/BIG-IP Next CNF ZebOS BGP denial of service (K000137315)


๐Ÿ“ˆ 19.01 Punkte

๐Ÿ“Œ 3 Lessons That Are Informing the Next Generation of the Cyber Range


๐Ÿ“ˆ 18.48 Punkte

๐Ÿ“Œ Avoiding the Next Yemen: Applying Hard Lessons for Security Partnerships


๐Ÿ“ˆ 18.48 Punkte

๐Ÿ“Œ Lessons from COVID-19: Intelligence Failures and How to Prepare for the Next Global Crisis


๐Ÿ“ˆ 18.48 Punkte

๐Ÿ“Œ The password attacks of 2023: Lessons learned and next steps


๐Ÿ“ˆ 18.48 Punkte

๐Ÿ“Œ Lessons Learned: Adding ChatGPT to a Tic-Tac-Toe Game in Next.js


๐Ÿ“ˆ 18.48 Punkte

๐Ÿ“Œ Seagate stellt zu Open Compute Project kompatible 10-GByte/s-SSD vor


๐Ÿ“ˆ 17.74 Punkte

๐Ÿ“Œ Open Compute Project: Seagates PCIe-x16-SSD รผbertrรคgt Daten mit 10 GByte/s


๐Ÿ“ˆ 17.74 Punkte

๐Ÿ“Œ Open Compute: Facebook baut zweites Rechenzentrum in Europa


๐Ÿ“ˆ 17.74 Punkte











matomo