Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Desktop: Fixes #9985: Filter Sync Target Info Logs #10014

Merged
merged 7 commits into from
Mar 2, 2024

Conversation

criticic
Copy link
Contributor

Fixes #9985 .

  • Removes the Content & Checksum parameters from master keys
  • Truncates public key to first 40 characters
  • Truncates provate key to this format: "first20chars...last20chars"
  • Added testing to check this behaviour

Copy link
Contributor

github-actions bot commented Feb 27, 2024

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@criticic
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

github-actions bot added a commit that referenced this pull request Feb 27, 2024
@criticic criticic closed this Feb 27, 2024
@criticic criticic reopened this Feb 27, 2024
@criticic
Copy link
Contributor Author

The test fails due to a issue with cspell in the unit test, should I just disable it for this test?

@criticic
Copy link
Contributor Author

@PackElend label me please

Introduction URL: https://discourse.joplinapp.org/t/introducing-criticic/36240

Comment on lines 249 to 250
if (mk.content) delete mk.content;
if (mk.checksum) delete mk.checksum;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this check?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember some tests failing due to this, though they run fine now without it also. Not sure what caused the issue then.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok because I think with real data mk.checksum is an empty string so you wouldn't delete it in this case. And this check is unnecessary anyway

ppk_: {
value: {
// Public Key is truncated to 40 characters
publicKey: 'longstringverylongstringlongstringverylo',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind adding "..." to this string too to show it's truncated?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And please remove all the comments. They are not necessary and are likely to become outdated.

Comment on lines 225 to 228
activeMasterKeyId_: originalSyncInfo.activeMasterKeyId,
appMinVersion_: originalSyncInfo.appMinVersion,
e2ee_: originalSyncInfo.e2ee,
version_: originalSyncInfo.version,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you create a test you should not use dynamic data, especially not data that comes from the data you're supposed to check. So all these should be static strings/numbers.

createdTime: 0,
keySize: 0,
},
updatedTime: originalSyncInfo.ppk.updatedTime,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Comment on lines 218 to 219
createdTime: 0,
keySize: 0,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you try the app and use more realistic data? Checking that the time or size is 0 is not a good test - it might be 0 because of a bug.

@laurent22
Copy link
Owner

Please use this as test data:

{
	"version": 3,
	"e2ee": {
		"value": true,
		"updatedTime": 0
	},
	"activeMasterKeyId": {
		"value": "400227d2222c4d3bb7346514861c643b",
		"updatedTime": 0
	},
	"masterKeys": [
		{
			"id": "400227d8a77c4d3bb7346514861c643b",
			"created_time": 1515008161362,
			"updated_time": 1708103706234,
			"source_application": "net.cozic.joplin-desktop",
			"encryption_method": 4,
			"checksum": "",
			"content": "{\"iv\":\"M1uezlW1Pu1g3dwrCTqcHg==\",\"v\":1,\"iter\":10000,\"ks\":256,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"0dqWvU/PUVQ=\",\"ct\":\"wHXN5pk1s7qKX+2Y9puEGZGkojI1Pvc+TvZUKC6QCfwxtMK6C1Hmgvm53vAaeCMcCXPvGVLo9JwqINFhEgb0ux+KUFcCqgT1pNO2Sf/hJsH8PjaUvl0kwpC511zdnvY7Hk3WIpgXVKUevsQt9TkMK5e8y1JMsuuTD3fW7bEiv/ehe4CBSQ9eH1tWjr1qQ==\"}",
			"hasBeenUsed": true
		}
	],
	"ppk": {
		"value": {
			"id": "SNQ5ZCs61KDVUW2qqqqHd3",
			"keySize": 2048,
			"privateKey": {
				"encryptionMethod": 4,
				"ciphertext": "{\"iv\":\"Z2y11b4nCYvpmQ9gvxELug==\",\"v\":1,\"iter\":10000,\"ks\":256,\"ts\":64,\"mode\":\"ccm\",\"adata\":\"\",\"cipher\":\"aes\",\"salt\":\"0dqWvU/PUVQ=\",\"ct\":\"8CvjYayXMpLsrAMwtu18liRfewKfZVpRlC0D0I2FYziyFhRf4Cjqi2+Uy8kIC8au7oBSBUnNU6jd04ooNozneKv2MzkhbGlXo3izxqCMVHboqa2vkPWbBAxGlvUYQUg213xG61FjZ19ZJdpti+AQy7qpQU7/h5kyC0iJ2aXG5TIGcBuDq3lbGAVfG/RlL/abMKLYb8KouFYAJe+0bUajUXa1KJsey+eD+2hFVc+nAxKOLe1UoZysB77Lq43DRTBFGH2gTSC1zOXxuZeSbFPPN0Cj+FvV7D5pF9LhUSLPDsIiRwF/q+E506YgDjirSZAvW1Y2EEM22F2Mh0I0pbVPFXhhBafqPLRwXmUGULCnA64gkGwctK5mEs985VVSrpQ0nMvf/drg2vUQrJ3exgl43ddVSOCjeJuF7F06IBL5FQ34iAujsOheRNvlWtG9xm008Vc19NxvhtzIl1RO7XLXrrTBzbFHDrcHjda/xNWNEKwU/LZrH0xPgwEcwBmLItvy/NojI/JKNeck8R431QWooFb7cTplO4qsgCQNL9MJ9avpmNSXJAUQx8VnifKVbzcY4T7X7TmJWSrpvBWV8MLfi3TOF4kahR75vg47kCrMbthFMw5bvrjvMmGOtyKxheqbS5IlSnSSz5x7wIVz0g3vzMbcbb5rF5MuzNhU97wNiz3L1Aonjmnu8r3vCyXTB/4GSiwYH7KfixwYM68T4crqJ0VneNy+owznCdJQXnG4cmjxek1wmJMEmurQ1JtANNv/m43gzoqd62V6Dq05vLJF+n7CS9HgJ3FTqYVCZLGGYrSilIYnEjhdaBpkcnFrCitbfYj+IpNC6eN6qg2hpGAbmKId7RLOGwJyda0jkuNP9mTqWOF+6eYn8Q+Y3YIY\"}"
			},
			"publicKey": "-----BEGIN RSA PUBLIC KEY-----\nMIIBCgKCAQEAiSTY5wBscae/WmU3PfVP5FYQiuTi5V7BjPcge/6pXvgF3zwe43uy\nTWdzO2YgK/a8f3H507clcGlZN4e0e1jZ/rh4lMfaN\nugfNo0RAvuwn8Yniqfb69reygJywbFBIauxbBpVKbc21MLuCbPkVFjKG7qGNYdF4\nc17mQ8nQsbFPZcuvxsZvgvvbza1q0rqVETdDUClyIrY8plAjMgTKCRwq2gafP6eX\nWpkENAyIbOFxSKXjWy0yFidvZfYLz4mIRwIDAQAB\n-----END RSA PUBLIC KEY-----",
			"createdTime": 1633274368892
		},
		"updatedTime": 1633274368892
	},
	"appMinVersion": "0.0.0"
}

But really you should have looked for this data yourself or asked around. Testing with fake data with 0 values and empty strings is not something we can rely on.

@criticic
Copy link
Contributor Author

In this case I had first made it all static data (from the running Joplin App), but then decided to write it this way. (seemed cleaner to my brain) but yeah I agree it might not be suited for a test

@criticic
Copy link
Contributor Author

I think now this is in line with the feedback you provided

// Truncate the private key and public key
if (filtered.ppk_.value) {
filtered.ppk_.value.privateKey.ciphertext = `${filtered.ppk_.value.privateKey.ciphertext.substr(0, 20)}...${filtered.ppk_.value.privateKey.ciphertext.substr(-20)}`;
filtered.ppk_.value.publicKey = `${filtered.ppk_.value.publicKey.substr(0, 20)}...${filtered.ppk_.value.publicKey.substr(-20)}`;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not what was asked. The point of including the first 40 characters is to show the start of the public key data. With your change all we get is "-----BEGIN RSA PUBLI... RSA PUBLIC KEY-----" which is useless.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for the misunderstanding, have corrected it

@laurent22 laurent22 merged commit 9a2a251 into laurent22:dev Mar 2, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When printing sync target info to the log, filter the data
3 participants