Skip to content

Conversation

@ksykulev
Copy link
Contributor

fleetdm/fleet#20644
fleetdm/fleet#27914

This adds the jetbrains_plugins table. It contains a list of plugins installed on the system under a jetbrains product. Currently supported jetbrains products
CLion, DataGrip, GoLand, IntelliJIdea, IntelliJIdeaCommunityEdition, PhpStorm, PyCharm, PyCharmCommunityEdition, ReSharper, Rider, RubyMine, RustRover, WebStorm

An important thing to note about this table is in order to get some of the details about each plugin we must go through the jar files in the lib directory of the plugin and scan for a "plugin.xml" file. This requires zlib and libarchive.

Here is a sample output

osquery> select product_type, name, version, vendor, path from users cross join jetbrains_plugins using (uid);
+---------------------------------+-------------------+---------------+-----------+-------------------------------------------------------------------------------------------------------------------+
| product_type                    | name              | version       | vendor    | path                                                                                                              |
+---------------------------------+-------------------+---------------+-----------+-------------------------------------------------------------------------------------------------------------------+
| intellij_idea                   | AWS Toolkit       | 3.51-243      | AWS       | /Users/ksykulev/Library/Application Support/JetBrains/IntelliJIdea2024.3/plugins/aws-toolkit-jetbrains-standalone |
| intellij_idea                   | Plugin DevKit     | 243.22562.218 | JetBrains | /Users/ksykulev/Library/Application Support/JetBrains/IntelliJIdea2024.3/plugins/devkit                           |
| intellij_idea                   | GitHub Copilot    | 1.5.30-242    | GitHub    | /Users/ksykulev/Library/Application Support/JetBrains/IntelliJIdea2024.3/plugins/github-copilot-intellij          |
| intellij_idea                   | Swing UI Designer | 243.22562.218 | JetBrains | /Users/ksykulev/Library/Application Support/JetBrains/IntelliJIdea2024.3/plugins/uiDesigner                       |
| intellij_idea                   | AWS Core          | 3.51-243      | AWS       | /Users/ksykulev/Library/Application Support/JetBrains/IntelliJIdea2024.3/plugins/plugin-core                      |
| intellij_idea_community_edition | Docker            | 251.26094.133 | JetBrains | /Users/ksykulev/Library/Application Support/JetBrains/IdeaIC2025.1/plugins/clouds-docker-impl                     |
| intellij_idea_community_edition | AWS Toolkit       | 3.74-251      | AWS       | /Users/ksykulev/Library/Application Support/JetBrains/IdeaIC2025.1/plugins/aws-toolkit-jetbrains-standalone       |
| intellij_idea_community_edition | GitHub Copilot    | 1.5.46-243    | GitHub    | /Users/ksykulev/Library/Application Support/JetBrains/IdeaIC2025.1/plugins/github-copilot-intellij                |
| intellij_idea_community_edition | AWS Core          | 3.74.251      | AWS       | /Users/ksykulev/Library/Application Support/JetBrains/IdeaIC2025.1/plugins/plugin-core                            |
+---------------------------------+-------------------+---------------+-----------+-------------------------------------------------------------------------------------------------------------------+

@ksykulev ksykulev requested review from a team as code owners June 10, 2025 00:16
"Linux,Darwin,Windows:gflags"
"Linux,Darwin,Windows:glog"
"Linux,Darwin,Windows:googletest"
"Linux,Darwin,Windows:zlib"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a change to note. libarchive now needs to be compiled with zlib in order to extract the jar files. See the libraries/cmake/source/libarchive/CMakeLists.txt file for details. This means that zlib now needs to be compiled prior to libarchive.

return std::make_unique<PluginAttributes>(parsePluginXml(xml_content));
}

/*
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ksykulev ksykulev force-pushed the jetbrains-plugins-table branch from f538480 to 573fb4d Compare June 10, 2025 00:25
)
target_link_libraries(thirdparty_libarchive PRIVATE
zlibstatic
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this the right way to compile with zlib?

std::vector<char> content;
};

FileData extractSpecificFileFromArchive(const std::string& archive_file_path,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wonder if this should be in some common util location, it's a very generic method.

@ksykulev ksykulev force-pushed the jetbrains-plugins-table branch 3 times, most recently from c5d4c54 to 292cba1 Compare June 10, 2025 15:52
};

// Function to extract the contents of a specific tag
std::string getContentFromTag(const std::string& xml,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a duplicate of getTagContent from https://github.com/osquery/osquery/blob/master/osquery/tables/system/windows/programs.cpp#L43C13-L43C26

I don't want to make it part of this PR, but I feel like I should extract some of this simple XML parsing logic into some sort of shared util.
https://github.com/osquery/osquery/blob/master/osquery/tables/system/windows/programs.cpp#L23-L67

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Caught by this:
https://github.com/osquery/osquery/actions/runs/15562331436/job/43817632273

osquery_tables_system_systemtable.lib(programs.cpp.obj) : error LNK2005: "class std::basic_string<char, ... > osquery::tables::getTagContent(...)" is already defined.

@ksykulev ksykulev force-pushed the jetbrains-plugins-table branch 4 times, most recently from ca7c738 to 3c0c57a Compare June 10, 2025 20:20
QueryData results;

auto users = usersFromContext(context);
for (const auto& user : users) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another thing to note here, jetbrains plugins are installed at a user level.

Copy link
Contributor

@lucasmrod lucasmrod left a comment

Choose a reason for hiding this comment

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

LGTM!

Left some questions/comments.

@ksykulev ksykulev force-pushed the jetbrains-plugins-table branch 2 times, most recently from a762135 to c86bb40 Compare June 11, 2025 03:23
deinitUsersAndGroupsServices(true, false);
Dispatcher::instance().resetStopping();
}
#endif
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not having this block was making the windows test fail. I see that usersFromContext(context) fails without it.

80: E20250611 01:13:27.886477  7396 registry_factory.cpp:188] table registry users plugin caused exception: no state
80: E20250611 01:13:27.886477  7396 virtual_table.cpp:1052] Exception while executing table jetbrains_plugins: no state

@ksykulev ksykulev force-pushed the jetbrains-plugins-table branch 2 times, most recently from e7b2b71 to 55db4dd Compare June 11, 2025 04:38
@ksykulev ksykulev force-pushed the jetbrains-plugins-table branch from 55db4dd to 4b56279 Compare June 11, 2025 05:10
@ksykulev
Copy link
Contributor Author

The path was incorrect on windows. It is now fixed and returning correct results.
Screenshot 2025-06-11 at 12 11 59 AM

lucasmrod
lucasmrod previously approved these changes Jun 11, 2025
Copy link
Contributor

@lucasmrod lucasmrod left a comment

Choose a reason for hiding this comment

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

LGTM!

@ksykulev
Copy link
Contributor Author

The linux paths were incorrect. 🤦
Screenshot 2025-06-11 at 5 05 40 PM

Tested and corrected.
Screenshot 2025-06-11 at 5 03 22 PM

@ksykulev
Copy link
Contributor Author

Just for completeness a screenshot from my mac
Screenshot 2025-06-11 at 5 10 37 PM

@zwass zwass merged commit 2e1a79d into osquery:master Jun 11, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants