Commit Graph
29 Commits
Author SHA1 Message Date
singhharsh1708 0d1e30f654 fix: treat empty boolean config as off in the js logger 2026-11-18 23:34:03 +05:30
Jash 58f65af18e fix: stop percent-encoding client log messages before they are posted refs #5816 2026-11-14 18:46:13 +05:30
Isaac Connor 1c878be614 refs #4981 log a stack trace from the error-level JS loggers
Now that zmError/zmFatal/zmPanic no longer shadow the native Error
constructor, build a real Error from the message and report its stack
via logReport. This records where the log call originated instead of
just the bare message. An Error passed in directly is used as-is.
The console output and alert() behaviour are unchanged.
2026-07-11 11:48:08 -07:00
Isaac Connor a503c993bb refs #4981 rename JS logger globals to zm-prefixed names
The JS logger defined seven global functions with very common names:
Panic, Fatal, Error, Warning, Info, Debug and Dump. The Error() one
shadowed the native window.Error constructor, so every `new Error()`
in the bundled third-party libraries (hls.js, jquery, moment,
bootstrap, ...) was silently hijacked once logger.js loaded. The rest
polluted the global namespace and could collide with plugins.

Rename the definitions to zmPanic, zmFatal, zmError, zmWarning, zmInfo,
zmDebug and zmDump, and update the only ZM call sites (all calls to the
former Error()): montage_common.js, event.js and skin.js. Native
`new Error()`, `throw Error()` and `reject(Error())` uses are left
untouched. No back-compat alias for Error() is added because that would
reintroduce the shadowing bug.
2026-07-11 11:48:08 -07:00
Isaac ConnorandClaude Opus 4.8 cd3aaff0fd feat: add ZM_LOG_BROWSER_EXTENSIONS config to optionally log extension errors refs #3340
#4914 unconditionally drops Javascript errors and CSP violations sourced from
browser extensions. Some operators want to know when a plugin is touching the
ZoneMinder tab, so gate the suppression behind a config entry.

Add ZM_LOG_BROWSER_EXTENSIONS (boolean, default no) in the logging category.
It is exposed to JS by the existing non-private-config loop in skin.js.php as
the string '0'/'1' (the same convention as ZM_LOG_INJECT), so logger.js only
filters extension sources when it is '0'. Default behaviour is unchanged:
extension noise stays out of the log.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-18 20:33:15 -04:00
Isaac ConnorandCopilot Autofix powered by AI c490ce6194 Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-06-17 15:39:15 -04:00
SteveGilvarryandClaude Opus 4.8 6044663fc4 fix: don't log browser-extension errors and CSP violations
The client-side logger reported every window.onerror and
securitypolicyviolation event, including ones injected by browser
extensions (ad blockers, password managers, etc.). Those fire on every
page, are not ZoneMinder's code, and spam the web_js log with entries
like "inline violated CSP script-src at moz-extension line 46".

Ignore reports whose source is a browser extension
(moz-extension/chrome-extension/safari-web-extension/webkit-masked-url),
checking both the error/source URL and the CSP sourceFile/blockedURI.
Legitimate same-origin errors and CSP violations are still logged.

fixes #3340

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-13 20:32:54 +10:00
Isaac ConnorandClaude Opus 4.6 667548dc43 fix: remove unused catch parameter in logger.js to satisfy eslint
The catch block for the strict-mode arguments.callee TypeError
doesn't need the exception object since the failure is expected.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 09:09:42 -05:00
Isaac ConnorandClaude Opus 4.6 812251f40f fix: improve JS error logging for undefined messages and cross-origin errors
window.onerror now captures column number and error stack trace when
available. Undefined or browser-sanitized "Script error." messages get a
descriptive placeholder instead of logging "undefined". Caller name
introspection is guarded against strict mode and empty names.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 22:16:23 -05:00
Isaac Connor f0cd36989b Spacing, use const and let instead of var 2022-10-21 18:11:46 -04:00
Isaac Connor 5a5a665cdf Test for definition of ZM_LOG_INJECT. We don't include the config when not logged in. So it won't be defined 2022-10-12 19:34:05 -04:00
Isaac Connor cb3fc5907d Use canEdit['System'] and value of new ZM_LOG_INJECT to disable attempting to inject javascript errors into zm logs 2022-10-06 14:52:39 -04:00
Isaac Connor 3639593ae5 use js.post instead of getJSON. 2021-01-11 15:22:15 -05:00
Andrew Bauer 72eaf267c1 eslint 2021-01-08 10:45:59 -06:00
Andrew Bauer c0431eca86 eslint 2021-01-08 10:42:45 -06:00
Andrew Bauer 55d99e8e7c eslint 2021-01-08 10:10:47 -06:00
Andrew Bauer b56883a985 add reference to browserInfo function 2021-01-08 09:35:32 -06:00
Andrew Bauer 62fc1fb1aa replace Mootools Browser object with our own 2021-01-08 09:32:51 -06:00
Andrew Bauer 9209f40daa eslint 2020-12-24 14:59:27 -06:00
Andrew Bauer 3fd50bb01d reorganize logger.js and use jquery 2020-12-24 14:32:23 -06:00
Isaac Connor fe96ba0a2a cleanup and revert adding Event stack trace 2020-04-10 11:14:46 -04:00
Isaac Connor d7ea798c09 add modern stracktrace to log messages 2020-03-20 11:06:32 -04:00
Matt N f0b33145f5 Log CSP violations in ZM logs in supported browsers (#2431) 2019-01-21 11:12:17 -05:00
Matt N a1a42345e3 More eslint fixes; eslint in php; add eslint to travis (#2419)
* Add eslint to travis.yml

* Update eslint package versions and apply new indent rules

* Enable the brace-style and block-style eslint rules

* Enable the 'curly' eslint rule

* Enable the 'keyword-spacing' eslint rule

* Enable the 'key-spacing' eslint rule

* Enable the 'object-curly-spacing' eslint rule

* Enable the 'no-new-object' eslint rule

* Only disable the no-caller eslint rule in the one affected file

* Enable the 'no-unused-vars' eslint rule for local variables

* Add linting of JS in .php files
2019-01-19 10:32:40 -05:00
Isaac Connor 1e50df741f fix some memleaks 2017-11-28 09:50:09 -05:00
Matthew Noorenberghe c7955cd1b6 Add eslint configuration files extending Google's rules 2017-03-18 00:02:17 -07:00
Andy Bauer 254fcbcef7 update gpl 2 mailing address in source files 2016-12-26 09:23:16 -06:00
Isaac Connor ebe35c2135 handle empty [file] to prevent logzilla 2014-11-13 09:17:54 -05:00
stan 6ff385e407 git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@3459 e3e1d417-86f3-4887-817a-d78f3d33393f 2011-06-21 09:19:10 +00:00