Skip to content

DBLogger: String or binary data would be truncated #61

@homestar9

Description

@homestar9

What are the steps to reproduce this issue?

  1. Activate CBSecurity DB Logger
  2. Within Testbox, create an integration test that will trigger a cbSecurity rule (e.g. get( "/api/v1/secure/" );)
  3. Note the exception: "Error Executing Database Query.[Macromedia][SQLServer JDBC Driver][SQLServer]String or binary data would be truncated."

What happens?

The resulting SQL could use values longer than the allocated 255 varchar column length. Here's some sample SQL that could be generated within Testbox. Note the referer column is greater than 255 characters.

INSERT INTO cbsecurity_logs(
	id,
	logdate,
	action,
	blocktype,
	ip,
	host,
	httpmethod,
	path,
	querystring,
	referer,
	useragent,
	userid,
	securityrule
)VALUES (
	'dabef304-d42c-4dbd-a6cd-819b1ca3b1a6',
	2025-12-25 11:26:04.596,
	'override',
	'authorization',
	'127.0.0.1',
	'127.0.0.1:60830',
	'GET',
	'',
	'method=runRemote&directory=&testSpecs=CDD465F2506F60710FBB83B2A51FCB5582B4BCDD3099EB8AA58FE02F761A6DB1&testBundles=tests%2Especs%2Eintegration%2EUserRolesTest&opt_run=true&coverageEnabled=false',
	'http://127.0.0.1:60830/tests/specs/integration/UserRolesTest.cfc?method=runRemote&directory=&testSpecs=CDD465F2506F60710FBB83B2A51FCB5582B4BCDD3099EB8AA58FE02F761A6DB1&testBundles=tests%2Especs%2Eintegration%2EUserRolesTest&opt_run=true&coverageEnabled=false',
	'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36',
	'7',
	'{"permissions":"","whiteList":"","scopes":"admin","secureList":"v1:users"...

What were you expecting to happen?

Expected the log to be written to the DB

Any other comments?

Two ideas for fixing the issue:

  1. Assign queryString and referer to VARCHAR(max) (or getTextColumnType())
  2. Alternatively, trim the string upon entry to the first 255 characters.

What versions are you using?

Package Version: 3.6.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions