Skip to content

Comments

Instead of manually updating the version, reason from plugin.json#164

Merged
Rajat-Dabade merged 4 commits intomainfrom
read-version-from-plugin-json-file
Feb 17, 2026
Merged

Instead of manually updating the version, reason from plugin.json#164
Rajat-Dabade merged 4 commits intomainfrom
read-version-from-plugin-json-file

Conversation

@Rajat-Dabade
Copy link
Contributor

@Rajat-Dabade Rajat-Dabade commented Feb 2, 2026

Summary

Removed the need to manually update the board version in different parts of the code. Now, the version is automatically read from the plugin.json file and used everywhere.

Ticket Link

https://mattermost.atlassian.net/browse/MM-67360

Summary by CodeRabbit

  • Chores
    • Updated build process to automatically derive plugin version and release notes URL from Git tags and build metadata.
    • Simplified plugin manifest by removing static version and release notes URL fields; these values are now generated dynamically at build time.

@Rajat-Dabade Rajat-Dabade self-assigned this Feb 2, 2026
@Rajat-Dabade Rajat-Dabade added 2: Dev Review Requires review by a core committer 3: QA Review Requires review by a QA tester labels Feb 2, 2026
Copy link
Member

@marianunez marianunez left a comment

Choose a reason for hiding this comment

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

@Rajat-Dabade we would also need to remove it from the plugin.json so the build process of the bundle can generate it and set from the tag - removing that manual step. See example: mattermost/mattermost-plugin-msteams-meetings#169

@marianunez marianunez removed the request for review from hmhealey February 2, 2026 16:13
@harshilsharma63
Copy link
Member

We'd still need to make the other changes, for example, from this PR - https://github.com/mattermost/mattermost-plugin-boards/pull/156/changes right?

a-voronkov pushed a commit to fambear/mattermost-plugin-boards that referenced this pull request Feb 3, 2026
- mattermost#159: Bump lodash 4.17.21 → 4.17.23 (Prototype Pollution fix, SNYK-JS-LODASH-15053838)
- mattermost#164: Read versionString from plugin.json manifest instead of hardcoding

Cherry-picked from mattermost/mattermost-plugin-boards
@coderabbitai
Copy link

coderabbitai bot commented Feb 8, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch read-version-from-plugin-json-file

Comment @coderabbitai help to get the list of available commands and usage tips.

@dryrunsecurity
Copy link

dryrunsecurity bot commented Feb 10, 2026

DryRun Security

🟡 Please give this pull request extra attention during review.

This pull request introduces multiple build-time injection risks: the Makefile in build/setup.mk unsafely interpolates git outputs into a shell command (allowing command injection), and the build/manifest tool writes unescaped manifest data into a JS template literal (allowing code injection / XSS via backticks, ${ sequences, or closing script patterns). Together these flaws can let malicious git tags or manifest fields execute arbitrary shell commands during builds or arbitrary JavaScript in the webapp.

🟡 Potential Cross-Site Scripting in build/manifest/main.go
Vulnerability Potential Cross-Site Scripting
Description The generator embeds the raw JSON text into a JavaScript source-level template using backtick-delimited string interpolation without fully escaping characters that can break out of the JS template context. The code only replaces literal newline escape sequences (\n -> \\n) but does not escape backticks (`), ${ sequence, or closing </script> patterns that can lead to executable injection when the generated file is served to a browser. Since manifest fields (homepage_url, release_notes_url, name, description, etc.) can originate from external inputs (or in some build setups be influenced by tags or repo data), an attacker-controlled value containing a backtick or a template substitution sequence could terminate or alter the JS and inject code, resulting in XSS.

manifestStr = strings.ReplaceAll(manifestStr, `\n`, `\\n`)
// write generated code to file by using JS file template.
if err := os.WriteFile(

Command Injection in Build Process in build/setup.mk
Vulnerability Command Injection in Build Process
Description The Makefile in build/setup.mk executes a shell command using $(shell ...) to compile the manifest tool. During this process, it interpolates the output of git describe and git tag directly into the -ldflags argument of the go build command. Because Make variables are expanded as raw strings without any shell escaping, a maliciously crafted git tag (e.g., containing single quotes, semicolons, or backticks) can break out of the command's quoting and execute arbitrary shell commands on the build system. This affects any environment where make is run, including CI/CD runners and developer machines.

$(shell cd build/manifest && $(GO) build -ldflags '-X "main.BuildHashShort=$(BUILD_HASH_SHORT)" -X "main.BuildTagLatest=$(BUILD_TAG_LATEST)" -X "main.BuildTagCurrent=$(BUILD_TAG_CURRENT)"' -o ../bin/manifest)
# Ensure that the deployment tools are compiled. Go's caching makes this quick.
$(shell cd build/pluginctl && $(GO) build -o ../bin/pluginctl)

Build-time Code Injection in build/manifest/main.go
Vulnerability Build-time Code Injection
Description The build/manifest tool generates a TypeScript file (webapp/src/manifest.ts) by interpolating a JSON-marshaled manifest into a JavaScript template literal. The tool fails to escape backticks () and the interpolation sequence (${) which are special characters in JavaScript template literals. If any field in the manifest (such as version, which can be derived from git tags, or name/descriptionfromplugin.json) contains these characters, they will be executed as arbitrary JavaScript when the webapp loads the manifest. For example, a version tag like v1.0.0-${alert(1)}` would trigger an execution in the browser of any user using the plugin.

[]byte(fmt.Sprintf(pluginIDJSFileTemplate, manifestStr)),
0600,
); err != nil {
return errors.Wrap(err, "failed to write webapp/src/manifest.ts")


All finding details can be found in the DryRun Security Dashboard.

@marianunez
Copy link
Member

For testing this one, we just need to validate the version when it's built from the tag at release time so we can do this post merge @yasserfaraazkhan

@marianunez marianunez removed the 3: QA Review Requires review by a QA tester label Feb 10, 2026
@marianunez marianunez removed the request for review from yasserfaraazkhan February 10, 2026 15:47
@Rajat-Dabade
Copy link
Contributor Author

We'd still need to make the other changes, for example, from this PR - #156 (changes) right?

@harshilsharma63 everything is now taken care of.

import manifest from '../../plugin.json'
// This file is automatically generated. Do not modify it manually.

const manifest = JSON.parse(`
Copy link
Member

Choose a reason for hiding this comment

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

Not sure whats the reason behind this change. Can you add code comment explaining why we cannot import plugin.json as I think someone will be confused in the future as well.

Copy link
Contributor Author

@Rajat-Dabade Rajat-Dabade Feb 14, 2026

Choose a reason for hiding this comment

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

Added the comments.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, got it. It's an autogenerated file.

@Rajat-Dabade Rajat-Dabade merged commit 7027d65 into main Feb 17, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2: Dev Review Requires review by a core committer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants