diff --git a/integration/ApprovedNativeV8Projection.h b/integration/ApprovedNativeV8Projection.h index d337d5551..c444c726c 100644 --- a/integration/ApprovedNativeV8Projection.h +++ b/integration/ApprovedNativeV8Projection.h @@ -46,7 +46,7 @@ inline bool projectNativeGraph(juce::var& snapshot,const juce::var& bus, if(!rows||rows->isEmpty()||!edges||!nativeV8Decimal(rev)|| !nativeV8Decimal(roster))return false; juce::Array channels,wires,destinations; - std::unordered_set ids,edgeIds; + std::unordered_set ids,edgeIds,fxInstanceTokens; auto meters=std::make_unique(); juce::String mainId; for(const auto& row:*rows) { @@ -64,7 +64,8 @@ inline bool projectNativeGraph(juce::var& snapshot,const juce::var& bus, (format!="MONO"&&format!="STEREO")|| !out.isString()||!nativeV8Number(fader,linear)|| !nativeV8Number(pan,p)||linear<0.||linear>4.||p< -1.||p>1.|| - !mute.isBool()||!solo.isBool()||!inserts.isArray())return false; + !mute.isBool()||!solo.isBool()||!inserts.isArray()|| + inserts.getArray()->size()>8)return false; if(role=="MAIN"){if(mainId.isNotEmpty())return false;mainId=id.toString();} auto ch=std::make_unique(); ch->setProperty("id",id);ch->setProperty("name",name); @@ -93,7 +94,9 @@ inline bool projectNativeGraph(juce::var& snapshot,const juce::var& bus, if(!token.isString()||token.toString().isEmpty()|| !catalog.isString()||catalog.toString().isEmpty()|| catalog.toString().getNumBytesAsUTF8()>256|| - !label.isString()||!bypass.isBool())return false; + !label.isString()||!bypass.isBool()|| + !fxInstanceTokens.insert(token.toString().toStdString()).second) + return false; auto insert=std::make_unique(); insert->setProperty("id",token);insert->setProperty("catalogId",catalog); insert->setProperty("name",label); diff --git a/tests/approved_native_v8_projection_test.cpp b/tests/approved_native_v8_projection_test.cpp index c513da207..744dfc406 100644 --- a/tests/approved_native_v8_projection_test.cpp +++ b/tests/approved_native_v8_projection_test.cpp @@ -114,6 +114,46 @@ static void nativeInsertCatalogInstanceProjectionRegression() { const auto before=juce::JSON::toString(untouched,false); assert(!projectApprovedNativeV8(untouched,invalid,true)); assert(juce::JSON::toString(untouched,false)==before); + + // M6: the native projection is the first fail-closed boundary for + // unstable VST3 lease tokens. JS must never be asked to guess which + // physical plugin/editor is owned by a duplicated instance identity. + const auto rejectUnchanged=[](const juce::var& bus) { + auto untouched=canonicalSnapshot(); + const auto before=juce::JSON::toString(untouched,false); + assert(!projectApprovedNativeV8(untouched,bus,true)); + assert(juce::JSON::toString(untouched,false)==before); + }; + auto duplicateAcrossChannels=juce::JSON::parse( + juce::JSON::toString(source,false)); + duplicateAcrossChannels.getProperty("channels",{})[1].getDynamicObject() + ->setProperty("inserts", + duplicateAcrossChannels.getProperty("channels",{})[0] + .getProperty("inserts",{})); + rejectUnchanged(duplicateAcrossChannels); + + auto duplicateSameChannel=juce::JSON::parse( + juce::JSON::toString(source,false)); + auto* existing=duplicateSameChannel.getProperty("channels",{})[0] + .getProperty("inserts",{}).getArray(); + assert(existing && existing->size()==1); + existing->add(juce::JSON::parse(juce::JSON::toString((*existing)[0],false))); + rejectUnchanged(duplicateSameChannel); + + auto overfullRack=juce::JSON::parse( + juce::JSON::toString(source,false)); + juce::Array nine; + for(int i=0;i<9;++i) { + auto fx=std::make_unique(); + fx->setProperty("instanceId","unique-FX-"+juce::String(i+1)); + fx->setProperty("id","vendor.eq.catalog"); + fx->setProperty("name","Vendor EQ"); + fx->setProperty("bypassed",false); + nine.add(juce::var(fx.release())); + } + overfullRack.getProperty("channels",{})[0].getDynamicObject() + ->setProperty("inserts",juce::var(nine)); + rejectUnchanged(overfullRack); } static void noMutationOnReject(juce::var snapshot,juce::var bus,bool admitted) {