Compare commits
46 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ff7da312a0 | |||
| af175e078c | |||
| 09c3aa6fa6 | |||
| 84d69cad92 | |||
| 30aa53c049 | |||
| e5c2b7d428 | |||
| 742b91bd90 | |||
| 94e9b3de43 | |||
| 76a01082fe | |||
| 90f630d07c | |||
| 2361c555ed | |||
| 4345e9cf92 | |||
| 515fa59dcd | |||
| c171fefc5e | |||
| ca3e610df2 | |||
| c4a79dc07a | |||
| a7d467534c | |||
| 4c9ef78d4b | |||
| afadea311c | |||
| 49e7ba7597 | |||
| d9ac7f1fe1 | |||
| 8717509909 | |||
| b1465077a1 | |||
| 31fa528fe2 | |||
| 71a054b964 | |||
| 15c05b5667 | |||
| 9d0fb0901e | |||
| 87cc7b7e38 | |||
| 8f802c4574 | |||
| 942b4a3865 | |||
| c8d79ef509 | |||
| 8bd362922a | |||
| cb4d1366bf | |||
| e5cde7df45 | |||
| 50b051e155 | |||
| efe9250969 | |||
| 39e4e03b29 | |||
| eb97144726 | |||
| b695d0ff1f | |||
| c004b7c70a | |||
| b15be4bf7c | |||
| 5a3fd218bc | |||
| 9a33fc258f | |||
| 1781912d3f | |||
| 2a494213ff | |||
| 9cc4bb48fc |
@@ -0,0 +1 @@
|
|||||||
|
_
|
||||||
Executable
+9
@@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
if [ -z "$(cat "$1" | grep -E '(^fix:)|(^feature:)|(^up$)|^Merge branch .+$')" ] ; then
|
||||||
|
echo ""
|
||||||
|
echo respecte le format de commit ❤
|
||||||
|
echo " fix: xxx"
|
||||||
|
echo " feature: xxx"
|
||||||
|
echo ""
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
Executable
+7
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
if git diff --name-only HEAD@{1} HEAD | grep package-lock.json ; then
|
||||||
|
echo "📦 package-lock.json changed. Running npm ci to update your dependencies..."
|
||||||
|
npm ci
|
||||||
|
else
|
||||||
|
echo "📦 no need to update dependencies"
|
||||||
|
fi
|
||||||
Executable
+13
@@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
# prevent commits on master
|
||||||
|
branch="$(git rev-parse --abbrev-ref HEAD)"
|
||||||
|
if [ "$branch" = "master" ]; then
|
||||||
|
echo ""
|
||||||
|
echo "You can't commit directly to master branch"
|
||||||
|
echo "please create a pull request"
|
||||||
|
echo ""
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# run linters
|
||||||
|
npx lint-staged
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"*.js": ["eslint --fix", "prettier --write"],
|
||||||
|
"*.css": ["prettier --write"],
|
||||||
|
"*.jsx": ["prettier --write"],
|
||||||
|
"*.html.twig": ["twig-cs-fixer lint --fix", "myhtmlvalidate -q"],
|
||||||
|
"*.php": ["php-cs-fixer fix --config .php-cs-fixer.php"],
|
||||||
|
"Dockerfile": ["hadolint --ignore DL3002 --ignore DL3003 --ignore DL3008 --ignore DL3013 --ignore DL3016 --ignore DL3022"],
|
||||||
|
"*.md": ["markdownlint --fix"],
|
||||||
|
"*openapi.json": ["spectral lint"],
|
||||||
|
"*.tf": ["tflint"]
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
web/*
|
||||||
|
views/*
|
||||||
|
log/*
|
||||||
|
node_modules/*
|
||||||
|
coverage/*
|
||||||
|
data/*
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
export default {
|
||||||
|
tabWidth: 4,
|
||||||
|
singleQuote: true,
|
||||||
|
trailingComma: 'es5',
|
||||||
|
printWidth: 150,
|
||||||
|
arrowParens: 'always',
|
||||||
|
};
|
||||||
Generated
+792
-417
File diff suppressed because it is too large
Load Diff
+12
-11
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "vscodestat",
|
"name": "vscodestat",
|
||||||
"displayName": "vscodestat",
|
"displayName": "vscodestat",
|
||||||
"version": "1.1.142",
|
"version": "1.2.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"categories": [
|
"categories": [
|
||||||
"Other"
|
"Other"
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"compile": "tsc -p ./",
|
"compile": "tsc -p ./",
|
||||||
"lint": "eslint src --ext ts",
|
"lint": "eslint src --ext ts",
|
||||||
|
"prepare": "husky",
|
||||||
"pretest": "npm run compile && npm run lint",
|
"pretest": "npm run compile && npm run lint",
|
||||||
"test": "vscode-test",
|
"test": "vscode-test",
|
||||||
"vscode:prepublish": "npm run compile",
|
"vscode:prepublish": "npm run compile",
|
||||||
@@ -24,10 +25,6 @@
|
|||||||
},
|
},
|
||||||
"contributes": {
|
"contributes": {
|
||||||
"commands": [
|
"commands": [
|
||||||
{
|
|
||||||
"command": "vscodestat.helloWorld",
|
|
||||||
"title": "Hello World"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"command": "vscodestat.setUrl",
|
"command": "vscodestat.setUrl",
|
||||||
"title": "setUrl"
|
"title": "setUrl"
|
||||||
@@ -54,16 +51,20 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/mocha": "^10.0.10",
|
"@types/mocha": "^10.0.10",
|
||||||
"@types/node": "25.x",
|
"@types/node": "25.x",
|
||||||
"@types/vscode": "^1.108.1",
|
"@types/vscode": "^1.116.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^8.54.0",
|
"@typescript-eslint/eslint-plugin": "^8.59.1",
|
||||||
"@typescript-eslint/parser": "^8.54.0",
|
"@typescript-eslint/parser": "^8.59.1",
|
||||||
"@vscode/test-cli": "^0.0.12",
|
"@vscode/test-cli": "^0.0.12",
|
||||||
"@vscode/test-electron": "^2.5.2",
|
"@vscode/test-electron": "^2.5.2",
|
||||||
"eslint": "^9.39.2",
|
"eslint": "^10.1.0",
|
||||||
"typescript": "^5.9.3"
|
"husky": "^9.1.7",
|
||||||
|
"lint-staged": "^16.4.0",
|
||||||
|
"prettier": "^3.8.3",
|
||||||
|
"ts-api-utils": "^2.5.0",
|
||||||
|
"typescript": "^6.0.3"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"vscode": "^1.108.1"
|
"vscode": "^1.116.0"
|
||||||
},
|
},
|
||||||
"icon": "icon.png",
|
"icon": "icon.png",
|
||||||
"extensionKind": [
|
"extensionKind": [
|
||||||
|
|||||||
+2
-8
@@ -3,12 +3,6 @@ import * as vscode from 'vscode';
|
|||||||
export function activate(context: vscode.ExtensionContext) {
|
export function activate(context: vscode.ExtensionContext) {
|
||||||
console.log('Congratulations, your extension "vscodestat" is now active!');
|
console.log('Congratulations, your extension "vscodestat" is now active!');
|
||||||
|
|
||||||
// crée une commande de test
|
|
||||||
const disposable = vscode.commands.registerCommand('vscodestat.helloWorld', () => {
|
|
||||||
vscode.window.showInformationMessage('Hello World from vscodestat!');
|
|
||||||
});
|
|
||||||
context.subscriptions.push(disposable);
|
|
||||||
|
|
||||||
// commande pour definir l'url
|
// commande pour definir l'url
|
||||||
const disposable2 = vscode.commands.registerCommand('vscodestat.setUrl', async () => {
|
const disposable2 = vscode.commands.registerCommand('vscodestat.setUrl', async () => {
|
||||||
const url = await vscode.window.showInputBox({
|
const url = await vscode.window.showInputBox({
|
||||||
@@ -58,7 +52,7 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
// detecte un focus / blur de la fenetre vscode
|
// detecte un focus / blur de la fenetre vscode
|
||||||
vscode.window.onDidChangeWindowState(async event => {
|
vscode.window.onDidChangeWindowState(async event => {
|
||||||
console.log('Window state changed:', event.focused);
|
console.log('Window state changed:', event.focused);
|
||||||
await makeHttpRequest({ focus: event.focused });
|
await makeHttpRequest({ event: 'focus', focused: event.focused });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +63,7 @@ export function deactivate() { }
|
|||||||
* /root/docker/monitoringserver/controller/homeController.js
|
* /root/docker/monitoringserver/controller/homeController.js
|
||||||
* => monitoringserver
|
* => monitoringserver
|
||||||
*/
|
*/
|
||||||
function extractProjectName(path: string) {
|
export function extractProjectName(path: string) {
|
||||||
// des c'est l'un des fois l'autre ?
|
// des c'est l'un des fois l'autre ?
|
||||||
// /root/docker/vscodestat/src/extension.ts
|
// /root/docker/vscodestat/src/extension.ts
|
||||||
// \root\docker\vscodestat\src\extension.ts
|
// \root\docker\vscodestat\src\extension.ts
|
||||||
|
|||||||
@@ -1,15 +1,40 @@
|
|||||||
import * as assert from 'assert';
|
import * as assert from 'assert';
|
||||||
|
import { extractProjectName } from '../extension.js';
|
||||||
|
|
||||||
// You can import and use all API from the 'vscode' module
|
suite('extractProjectName', () => {
|
||||||
// as well as import your extension to test it
|
test('extrait le nom de projet depuis un path Linux /root/docker/X', () => {
|
||||||
import * as vscode from 'vscode';
|
assert.strictEqual(
|
||||||
// import * as myExtension from '../../extension';
|
extractProjectName('/root/docker/vscodestat/src/extension.ts'),
|
||||||
|
'vscodestat'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
suite('Extension Test Suite', () => {
|
test('extrait le nom de projet depuis un path Windows \\root\\docker\\X', () => {
|
||||||
vscode.window.showInformationMessage('Start all tests.');
|
assert.strictEqual(
|
||||||
|
extractProjectName('C:\\root\\docker\\monitoringserver\\controller\\homeController.js'),
|
||||||
|
'monitoringserver'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test('Sample test', () => {
|
test('retourne null pour un path hors /docker/', () => {
|
||||||
assert.strictEqual(-1, [1, 2, 3].indexOf(5));
|
assert.strictEqual(extractProjectName('/home/user/projet/file.js'), null);
|
||||||
assert.strictEqual(-1, [1, 2, 3].indexOf(0));
|
});
|
||||||
|
|
||||||
|
test('retourne null pour un path vide', () => {
|
||||||
|
assert.strictEqual(extractProjectName(''), null);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('extrait correctement quand le chemin contient docker plusieurs fois', () => {
|
||||||
|
assert.strictEqual(
|
||||||
|
extractProjectName('/root/docker/flatbay/lib/docker/foo.js'),
|
||||||
|
'flatbay'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('gere les paths avec tirets et chiffres', () => {
|
||||||
|
assert.strictEqual(
|
||||||
|
extractProjectName('/root/docker/gextra6/bin/console'),
|
||||||
|
'gextra6'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
REVIEW DE CODE — 2026-04-26
|
||||||
|
============================================
|
||||||
|
|
||||||
|
Extension VSCode (TypeScript) qui collecte des metriques sur
|
||||||
|
l'activite du user dans VSCode :
|
||||||
|
- ouverture de fichier / changement d'onglet (event 'open')
|
||||||
|
- sauvegarde de fichier (event 'save')
|
||||||
|
- focus/blur de la fenetre (event 'focus')
|
||||||
|
|
||||||
|
Envoie un POST JSON a la URL configuree (`vscodestat.url`).
|
||||||
|
|
||||||
|
NB : extension force-installed dans les containers vscode + vscodeluigi
|
||||||
|
(cf vscode/todo.txt). C'est l'extension de monitoring activite dev.
|
||||||
|
|
||||||
|
SECURITE
|
||||||
|
--------
|
||||||
|
[ ] vscodestat.url configurable user-side (CRITIQUE pour exfil)
|
||||||
|
src/extension.ts:14-23 : commande `setUrl` permet au user de
|
||||||
|
changer l'URL en runtime via `vscode.workspace.getConfiguration
|
||||||
|
().update('vscodestat.url', url, ConfigurationTarget.Global)`.
|
||||||
|
Le user peut donc rediriger ses metriques vers son propre
|
||||||
|
serveur. Dans le contexte (extension force-installed pour
|
||||||
|
tracking employe), le user peut bypass le tracking en
|
||||||
|
pointant sur `https://localhost/dummy` ou similar. Attendu /
|
||||||
|
pas attendu ?
|
||||||
|
NB : entrypoint.sh dans vscode/ overwrite la URL a chaque
|
||||||
|
boot du container. Donc tracking restored. Mais pendant la
|
||||||
|
session, user peut tweak. A documenter le comportement.
|
||||||
|
|
||||||
|
[ ] makeHttpRequest envoie au serveur l'event sans auth
|
||||||
|
src/extension.ts : `fetch(url, { method: 'POST',
|
||||||
|
headers: ..., body: JSON.stringify(json) })`. Pas de token.
|
||||||
|
Cote serveur (cf monitoringserver/todo.txt), `/vscodestat` est
|
||||||
|
aussi sans auth => tout le monde peut envoyer des metriques.
|
||||||
|
|
||||||
|
[ ] extractProjectName fuite des paths potentiellement sensibles
|
||||||
|
src/extension.ts :
|
||||||
|
const match = path.match(/\/docker\/([^/]+)/);
|
||||||
|
if (match) return match[1];
|
||||||
|
Si un user ouvre un fichier hors `/docker/X/...`, le
|
||||||
|
`extractProjectName` retourne null, donc `project: null`
|
||||||
|
envoye. Pas un leak direct, mais combine au tracking precis,
|
||||||
|
profile complet de l'activite hors-projet.
|
||||||
|
|
||||||
|
[ ] Le user peut DISABLE l'extension volontairement
|
||||||
|
Standard VSCode : un user peut desactiver toute extension.
|
||||||
|
Le force-install au boot du container la re-active, mais
|
||||||
|
pendant la session, l'employe peut couper le tracking.
|
||||||
|
Pattern de force-tracking discutable (transparency).
|
||||||
|
|
||||||
|
[ ] Pas de TLS pinning sur fetch
|
||||||
|
Si l'URL pointe vers HTTPS (probablement),
|
||||||
|
`monitoringserver.raphaelpiccolo.com`, certificat valide. OK
|
||||||
|
mais pas de pinning.
|
||||||
|
|
||||||
|
BUGS / FRAGILITE
|
||||||
|
----------------
|
||||||
|
[ ] Pas de batching
|
||||||
|
Chaque event = 1 fetch. Pas de queue + flush periodique.
|
||||||
|
Si reseau down, perte d'events (pas de retry). A capper.
|
||||||
|
|
||||||
|
[ ] makeHttpRequest catch silencieux
|
||||||
|
src/extension.ts : catch + console.error. Pas de
|
||||||
|
retry, pas de notification user. Si serveur down, events
|
||||||
|
perdus.
|
||||||
|
|
||||||
|
[ ] extractProjectName : path Windows hardcode au regex
|
||||||
|
src/extension.ts : replace `\\` -> `/` puis match
|
||||||
|
`/docker/(...)/`. OK pour les conventions /root/docker, mais
|
||||||
|
si project hors `docker/`, retourne null. A clarifier.
|
||||||
|
|
||||||
|
CONVENTIONS
|
||||||
|
-----------
|
||||||
|
[ ] Pas de README detaille sur l'integration serveur
|
||||||
|
README mentionne juste "Sample url". A documenter le format
|
||||||
|
JSON envoye et le comportement.
|
||||||
@@ -6,6 +6,11 @@
|
|||||||
"lib": [
|
"lib": [
|
||||||
"ES2022"
|
"ES2022"
|
||||||
],
|
],
|
||||||
|
"types": [
|
||||||
|
"node",
|
||||||
|
"mocha",
|
||||||
|
"vscode"
|
||||||
|
],
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"strict": true /* enable all strict type-checking options */
|
"strict": true /* enable all strict type-checking options */
|
||||||
|
|||||||
Reference in New Issue
Block a user