Implements Phases 1-8 of the TFTSR implementation plan. Rust backend (Tauri 2.x, src-tauri/): - Multi-provider AI: OpenAI-compatible, Anthropic, Gemini, Mistral, Ollama - PII detection engine: 11 regex patterns with overlap resolution - SQLCipher AES-256 encrypted database with 10 versioned migrations - 28 Tauri IPC commands for triage, analysis, document, and system ops - Ollama: hardware probe, model recommendations, pull/delete with events - RCA and blameless post-mortem Markdown document generators - PDF export via printpdf - Audit log: SHA-256 hash of every external data send - Integration stubs for Confluence, ServiceNow, Azure DevOps (v0.2) Frontend (React 18 + TypeScript + Vite, src/): - 9 pages: full triage workflow NewIssue→LogUpload→Triage→Resolution→RCA→Postmortem→History+Settings - 7 components: ChatWindow, TriageProgress, PiiDiffViewer, DocEditor, HardwareReport, ModelSelector, UI primitives - 3 Zustand stores: session, settings (persisted), history - Type-safe tauriCommands.ts matching Rust backend types exactly - 8 IT domain system prompts (Linux, Windows, Network, K8s, DB, Virt, HW, Obs) DevOps: - .woodpecker/test.yml: rustfmt, clippy, cargo test, tsc, vitest on every push - .woodpecker/release.yml: linux/amd64 + linux/arm64 builds, Gogs release upload Verified: - cargo check: zero errors - tsc --noEmit: zero errors - vitest run: 13/13 unit tests passing Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
117 lines
3.6 KiB
JavaScript
117 lines
3.6 KiB
JavaScript
"use strict";
|
|
var utils = require("../utils");
|
|
|
|
function DataReader(data) {
|
|
this.data = data; // type : see implementation
|
|
this.length = data.length;
|
|
this.index = 0;
|
|
this.zero = 0;
|
|
}
|
|
DataReader.prototype = {
|
|
/**
|
|
* Check that the offset will not go too far.
|
|
* @param {string} offset the additional offset to check.
|
|
* @throws {Error} an Error if the offset is out of bounds.
|
|
*/
|
|
checkOffset: function(offset) {
|
|
this.checkIndex(this.index + offset);
|
|
},
|
|
/**
|
|
* Check that the specified index will not be too far.
|
|
* @param {string} newIndex the index to check.
|
|
* @throws {Error} an Error if the index is out of bounds.
|
|
*/
|
|
checkIndex: function(newIndex) {
|
|
if (this.length < this.zero + newIndex || newIndex < 0) {
|
|
throw new Error("End of data reached (data length = " + this.length + ", asked index = " + (newIndex) + "). Corrupted zip ?");
|
|
}
|
|
},
|
|
/**
|
|
* Change the index.
|
|
* @param {number} newIndex The new index.
|
|
* @throws {Error} if the new index is out of the data.
|
|
*/
|
|
setIndex: function(newIndex) {
|
|
this.checkIndex(newIndex);
|
|
this.index = newIndex;
|
|
},
|
|
/**
|
|
* Skip the next n bytes.
|
|
* @param {number} n the number of bytes to skip.
|
|
* @throws {Error} if the new index is out of the data.
|
|
*/
|
|
skip: function(n) {
|
|
this.setIndex(this.index + n);
|
|
},
|
|
/**
|
|
* Get the byte at the specified index.
|
|
* @param {number} i the index to use.
|
|
* @return {number} a byte.
|
|
*/
|
|
byteAt: function() {
|
|
// see implementations
|
|
},
|
|
/**
|
|
* Get the next number with a given byte size.
|
|
* @param {number} size the number of bytes to read.
|
|
* @return {number} the corresponding number.
|
|
*/
|
|
readInt: function(size) {
|
|
var result = 0,
|
|
i;
|
|
this.checkOffset(size);
|
|
for (i = this.index + size - 1; i >= this.index; i--) {
|
|
result = (result << 8) + this.byteAt(i);
|
|
}
|
|
this.index += size;
|
|
return result;
|
|
},
|
|
/**
|
|
* Get the next string with a given byte size.
|
|
* @param {number} size the number of bytes to read.
|
|
* @return {string} the corresponding string.
|
|
*/
|
|
readString: function(size) {
|
|
return utils.transformTo("string", this.readData(size));
|
|
},
|
|
/**
|
|
* Get raw data without conversion, <size> bytes.
|
|
* @param {number} size the number of bytes to read.
|
|
* @return {Object} the raw data, implementation specific.
|
|
*/
|
|
readData: function() {
|
|
// see implementations
|
|
},
|
|
/**
|
|
* Find the last occurrence of a zip signature (4 bytes).
|
|
* @param {string} sig the signature to find.
|
|
* @return {number} the index of the last occurrence, -1 if not found.
|
|
*/
|
|
lastIndexOfSignature: function() {
|
|
// see implementations
|
|
},
|
|
/**
|
|
* Read the signature (4 bytes) at the current position and compare it with sig.
|
|
* @param {string} sig the expected signature
|
|
* @return {boolean} true if the signature matches, false otherwise.
|
|
*/
|
|
readAndCheckSignature: function() {
|
|
// see implementations
|
|
},
|
|
/**
|
|
* Get the next date.
|
|
* @return {Date} the date.
|
|
*/
|
|
readDate: function() {
|
|
var dostime = this.readInt(4);
|
|
return new Date(Date.UTC(
|
|
((dostime >> 25) & 0x7f) + 1980, // year
|
|
((dostime >> 21) & 0x0f) - 1, // month
|
|
(dostime >> 16) & 0x1f, // day
|
|
(dostime >> 11) & 0x1f, // hour
|
|
(dostime >> 5) & 0x3f, // minute
|
|
(dostime & 0x1f) << 1)); // second
|
|
}
|
|
};
|
|
module.exports = DataReader;
|