Skip to content
Permalink
Browse files

Added controls on mode switch when attached to remote Solr instance(s)

 - to prevent unwanted exposure of index entries about private
local/intranet documents when switching from "Intranet Indexing" mode
while attached to remote Solr instance(s)
 - to warn user about remote Solr instance(s) still attached when
switching from modes other than "Intranet Indexing"
  • Loading branch information...
luccioman committed Apr 11, 2018
1 parent 2af3bf7 commit 72808655a5035b54c5e559906592da129ea187b4
Showing with 55 additions and 20 deletions.
  1. +8 −0 htroot/ConfigBasic.html
  2. +47 −20 htroot/ConfigBasic.java
@@ -53,6 +53,14 @@ <h2>Basic Configuration</h2>
<li>
<img src="env/grafics/ok.png" height="16" width="16" alt="ok" />&nbsp;Use Case: what do you want to do with YaCy:<br />
<fieldset>
#(switchError)#::<div class="alert alert-danger" role="alert"><p>Can not leave from Intranet Indexing : one or more remote Solr instances are attached and may contain private documents indexed.</p>
<p>Please first delete all index entries (see the <a href="IndexControlURLs_p.html">URL Database Administration</a> page) or disconnect the remote Solr instance(s) from YaCy (see the <a href="IndexFederated_p.html">Index Sources &amp; Targets</a> page).</p></div>
#(/switchError)#
#(switchWarning)#::<div class="alert alert-warning" role="alert"><p>One or more remote Solr instances are attached and may contain indexed public documents irrelevant to your local domain.</p>
<p>You may want to delete all indexed documents (see the <a href="IndexControlURLs_p.html">URL Database Administration</a> page), disconnect or change the remote Solr instance(s) attached (see the <a href="IndexFederated_p.html">Index Sources &amp; Targets</a> page).</p></div>
::<div class="alert alert-warning" role="alert"><p>One or more remote Solr instances are attached.</p>
<p>Please be sure you want to expose the indexed documents in this new mode. You may want to disconnect or change the remote Solr instance(s) attached (see the <a href="IndexFederated_p.html">Index Sources &amp; Targets</a> page).</p></div>
#(/switchWarning)#
<table border="0">
<tr>
<td style="width: 256px;"><input type="radio" name="usecase" value="freeworld" id="usecaseFreeworld" #(freeworldChecked)#::checked="checked"#(/freeworldChecked)# /><label for="usecaseFreeworld">Community-based web search</label></td>
@@ -171,33 +171,60 @@ public static serverObjects respond(final RequestHeader header, final serverObje
}

// set a use case
prop.put("setUseCase_switchError", 0);
prop.put("setUseCase_switchWarning", 0);
String networkName = sb.getConfig(SwitchboardConstants.NETWORK_NAME, "");
if (post != null && post.containsKey("usecase")) {
boolean hasNonEmptyRemoteSolr = sb.index.fulltext().connectedRemoteSolr()
&& (sb.index.fulltext().collectionSize() > 0 || sb.index.fulltext().webgraphSize() > 0);
if ("freeworld".equals(post.get("usecase", "")) && !"freeworld".equals(networkName)) {
// switch to freeworld network
sb.setConfig(SwitchboardConstants.CORE_SERVICE_RWI, true);
sb.switchNetwork("defaults/yacy.network.freeworld.unit");
// switch to p2p mode
sb.setConfig(SwitchboardConstants.INDEX_DIST_ALLOW, true);
sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW, true);
sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW_SEARCH, true);
// set default behavior for search verification
sb.setConfig(SwitchboardConstants.SEARCH_VERIFY, "iffresh"); // nocache,iffresh,ifexist,cacheonly,false
sb.setConfig(SwitchboardConstants.SEARCH_VERIFY_DELETE, "true");
if("intranet".equals(networkName) && hasNonEmptyRemoteSolr) {
/* One or more non empty remote Solr(s) attached : disallow switching from intranet to another network to prevent disclosure of indexed private documents */
prop.put("setUseCase_switchError", 1);
} else {
if(hasNonEmptyRemoteSolr) {
/* One or more non empty remote Solr(s) attached : warn the user even if not coming from intranet as indexed documents may be irrelevant for the new mode */
prop.put("setUseCase_switchWarning", 2);
}
// switch to freeworld network
sb.setConfig(SwitchboardConstants.CORE_SERVICE_RWI, true);
sb.switchNetwork("defaults/yacy.network.freeworld.unit");
// switch to p2p mode
sb.setConfig(SwitchboardConstants.INDEX_DIST_ALLOW, true);
sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW, true);
sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW_SEARCH, true);
// set default behavior for search verification
sb.setConfig(SwitchboardConstants.SEARCH_VERIFY, "iffresh"); // nocache,iffresh,ifexist,cacheonly,false
sb.setConfig(SwitchboardConstants.SEARCH_VERIFY_DELETE, "true");
}
}
if ("portal".equals(post.get("usecase", "")) && !"webportal".equals(networkName)) {
// switch to webportal network
sb.setConfig(SwitchboardConstants.CORE_SERVICE_RWI, false);
sb.switchNetwork("defaults/yacy.network.webportal.unit");
// switch to robinson mode
sb.setConfig(SwitchboardConstants.INDEX_DIST_ALLOW, false);
sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW, false);
sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW_SEARCH, false);
// set default behavior for search verification
sb.setConfig(SwitchboardConstants.SEARCH_VERIFY, "ifexist"); // nocache,iffresh,ifexist,cacheonly,false
sb.setConfig(SwitchboardConstants.SEARCH_VERIFY_DELETE, "false");
if("intranet".equals(networkName) && hasNonEmptyRemoteSolr) {
/* One or more non empty remote Solr(s) attached : disallow switching from intranet to another network to prevent disclosure of indexed private documents */
prop.put("setUseCase_switchError", 1);
} else {
if(hasNonEmptyRemoteSolr) {
/* One or more non empty remote Solr(s) attached : warn the user even if not coming from intranet as indexed documents may be irrelevant for the new mode */
prop.put("setUseCase_switchWarning", 2);
}

// switch to webportal network
sb.setConfig(SwitchboardConstants.CORE_SERVICE_RWI, false);
sb.switchNetwork("defaults/yacy.network.webportal.unit");
// switch to robinson mode
sb.setConfig(SwitchboardConstants.INDEX_DIST_ALLOW, false);
sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW, false);
sb.setConfig(SwitchboardConstants.INDEX_RECEIVE_ALLOW_SEARCH, false);
// set default behavior for search verification
sb.setConfig(SwitchboardConstants.SEARCH_VERIFY, "ifexist"); // nocache,iffresh,ifexist,cacheonly,false
sb.setConfig(SwitchboardConstants.SEARCH_VERIFY_DELETE, "false");
}
}
if ("intranet".equals(post.get("usecase", "")) && !"intranet".equals(networkName)) {
if(hasNonEmptyRemoteSolr) {
/* One or more non empty remote Solr(s) attached : warn the user as the indexed documents may be public external resources out of scope for intranet/localhost domain. */
prop.put("setUseCase_switchWarning", 1);
}
// switch to intranet network
sb.setConfig(SwitchboardConstants.CORE_SERVICE_RWI, false);
sb.switchNetwork("defaults/yacy.network.intranet.unit");

0 comments on commit 7280865

Please sign in to comment.
You can’t perform that action at this time.