private String generateYaraString(String ruleName) {

		StringBuilder yaraString = new StringBuilder("\n\nrule " + ruleName + "\n");
		yaraString.append("{\n\tstrings:\n");

		String fullStr = "";

		// Get the "combined string" from the search data object; this is the ENTIRE set of 
		// instructions in one string, with all masking applied.
		if (dialog == null || dialog.getSearchData() == null) {
			return null;
		}
		String instrStr = dialog.getSearchData().getCombinedString();

		// Loop over the combined string, converting each nibble to hex. If we don't have enough
		// bytes to create a nibble, or if part of the nibble is masked, fill with a '?' char. This
		// is a Yara constraint - it can only handle displaying data down to the nibble level.
		//
		// ie: 10100110 -> A6
		//     101001.. -> A?
		//     ..11.001 -> ??
		//
		for (int i = 0; i < instrStr.length(); i += 8) {

			String curByte =
				instrStr.length() >= 8 ? instrStr.substring(i, i + 8) : instrStr.substring(i);
			String nibble1 = curByte.length() >= 4 ? curByte.substring(0, 4) : curByte.substring(0);
			String nibble2 = curByte.length() >= 8 ? curByte.substring(4, 8)
					: curByte.length() >= 4 ? curByte.substring(4) : "";

			if (nibble1.contains(".")) {
				fullStr += "?";
			}
			else {
				fullStr += InstructionSearchUtils.toHex(nibble1, false).trim();
			}

			if (nibble2.contains(".")) {
				fullStr += "?";
			}
			else {
				fullStr += InstructionSearchUtils.toHex(nibble2, false).trim();
			}

			fullStr += " ";
		}

		// Add the formatted string to our final output, and add some boilerplate Yara 
		// stuff.
		yaraString.append("\t\t$STR" + 1 + " = { " + fullStr + " }\n");
		yaraString.append("\n\tcondition:\n");
		yaraString.append("\t\t$STR1");
		yaraString.append("\n}\n");

		return yaraString.toString();
	}
Creates a correctly-formatted Yara string with masking where appropriate.
Yara strings have the following general format:

rule <rule name> { strings: $STR1 = { 4? 56 4? 55 4? 54 ?? 50 4? 8b ?? c7
4d 00 00 4?8d 1d 08 4e 00 00 }

condition: $STR1 }

@param ruleName
@return
Ghidra/Features/Base/ghidra_scripts/YaraGhidraGUIScript.java