Add yarn scripts for validation and building

main
Elbert Alias 5 years ago
parent 6e1aed86ff
commit 16795ce4bc

7
.gitignore vendored

@ -1,9 +1,5 @@
/build/* /build/*
/node_modules node_modules
/npm-debug.log
/npm-debug.log
package-lock.json
!.gitkeep !.gitkeep
@ -11,6 +7,7 @@ package-lock.json
Thumbs.db Thumbs.db
Desktop.ini Desktop.ini
*.DS_Store *.DS_Store
*.log
._* ._*
tags tags
tags.* tags.*

@ -1,4 +1,4 @@
# Wappalyzer [![Travis](https://travis-ci.org/aliasio/wappalyzer.svg?branch=master)](https://travis-ci.org/aliasio/wappalyzer/) [![Scrutinizer](https://scrutinizer-ci.com/g/AliasIO/Wappalyzer/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/aliasio/wappalyzer/?branch=master) # Wappalyzer [![Travis](https://travis-ci.org/aliasio/wappalyzer.svg?branch=master)](https://travis-ci.org/aliasio/wappalyzer/)
[Wappalyzer](https://www.wappalyzer.com/) is a [Wappalyzer](https://www.wappalyzer.com/) is a
[cross-platform](https://www.wappalyzer.com/nodejs) utility that uncovers the [cross-platform](https://www.wappalyzer.com/nodejs) utility that uncovers the

@ -0,0 +1,118 @@
const fs = require('fs')
const path = require('path')
const { apps: technologies, categories } = JSON.parse(
fs.readFileSync(path.resolve(`${__dirname}/../src/apps.json`))
)
try {
Object.keys(technologies).forEach((name) => {
const technology = technologies[name]
;['url', 'html', 'meta', 'headers', 'cookies', 'script', 'js'].forEach(
(type) => {
if (technology[type]) {
const keyed =
typeof technology[type] === 'string' ||
Array.isArray(technology[type])
? { _: technology[type] }
: technology[type]
Object.keys(keyed).forEach((key) => {
const patterns = Array.isArray(keyed[key])
? keyed[key]
: [keyed[key]]
patterns.forEach((pattern, index) => {
const id = `${name}: ${type}[${key === '_' ? `${index}` : key}]`
const [regex, ...flags] = pattern.split('\\;')
let maxGroups = 0
flags.forEach((flag) => {
const [key, value] = flag.split(':')
if (key === 'version') {
const refs = value.match(/\\(\d+)/g)
if (refs) {
maxGroups = refs.reduce((max, ref) =>
Math.max(max, parseInt(refs[1] || 0))
)
}
} else if (key === 'confidence') {
if (
!/^\d+$/.test(value) ||
parseInt(value, 10) < 0 ||
parseInt(value, 10) > 99
) {
throw new Error(
`Confidence value must a number between 0 and 99: ${value} (${id})`
)
}
} else {
throw new Error(`Invalid flag: ${key} (${id})`)
}
})
try {
// eslint-disable-next-line no-new
new RegExp(regex)
} catch (error) {
throw new Error(`${error.message} (${id})`)
}
const groups = new RegExp(`${regex}|`).exec('').length - 1
if (groups > maxGroups) {
throw new Error(
`Too many non-capturing groups, expected ${maxGroups}: ${regex} (${id})`
)
}
if (type === 'html' && !/[<>]/.test(regex)) {
throw new Error(
`HTML pattern must include < or >: ${regex} (${id})`
)
}
})
})
}
}
)
technology.cats.forEach((id) => {
if (!categories[id]) {
throw new Error(`No such category: ${id} (${name})`)
}
})
if (
technology.icon &&
!fs.existsSync(
path.resolve(
`${__dirname}/../src/drivers/webextension/images/icons/${technology.icon}`
)
)
) {
throw new Error(`No such icon: ${technology.icon} (${name})`)
}
try {
// eslint-disable-next-line no-new
const { protocol } = new URL(technology.website)
if (protocol !== 'http:' && protocol !== 'https:') {
throw new Error('Invalid protocol')
}
} catch (error) {
throw new Error(`Invalid website URL: ${technology.website} (${name})`)
}
// TODO check implies, excludes
})
} catch (error) {
// eslint-disable-next-line no-console
console.error(error.message)
}

2699
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -1,25 +1,22 @@
{ {
"dependencies": {
"file-type": "7.4.*",
"is-svg": "2.1.*",
"read-chunk": "2.1.*"
},
"devDependencies": { "devDependencies": {
"@nuxtjs/eslint-config": "^1.0.1", "@nuxtjs/eslint-config": "^1.0.1",
"@nuxtjs/eslint-module": "^1.2.0", "@nuxtjs/eslint-module": "^1.2.0",
"@prantlf/jsonlint": "^10.2.0",
"babel-eslint": "^10.1.0", "babel-eslint": "^10.1.0",
"chai": "^4.2.0", "convert-svg-to-png": "^0.5.0",
"dotenv": "^8.2.0", "dotenv": "^8.2.0",
"eslint": "^6.1.0", "eslint": "^6.1.0",
"eslint-config-prettier": "^4.1.0", "eslint-config-prettier": "^4.1.0",
"eslint-plugin-nuxt": "^0.5.2", "eslint-plugin-nuxt": "^0.5.2",
"eslint-plugin-prettier": "^3.1.3", "eslint-plugin-prettier": "^3.1.3",
"mocha": "^5.2.0",
"prettier": "^1.16.4" "prettier": "^1.16.4"
}, },
"scripts": { "scripts": {
"test": "mocha -R spec src", "validate:json": "jsonlint -qV ./schema.json ./src/apps.json && node ./bin/validate.js",
"lint": "eslint src", "validate": "yarn validate:json",
"lint:fix": "eslint src --fix" "convert": "cd ./src/drivers/webextension/images/icons ; cp *.svg converted ; cd converted ; convert-svg-to-png *.svg --width 32 --height 32 ; rm *.svg",
"jsonprettify": "jsonlint -si --trim-trailing-commas --enforce-double-quotes ./src/apps.json",
"build": "yarn validate && yarn jsonprettify"
} }
} }

@ -1,5 +1,5 @@
{ {
"title": "Wappalyzer Schema", "title": "Wappalyzer schema",
"definitions": { "definitions": {
"non-empty-non-blank-string": { "non-empty-non-blank-string": {
"type": "string", "type": "string",

File diff suppressed because it is too large Load Diff