external_refs rework
This commit is contained in:
@@ -3,6 +3,9 @@ An alternative view of issues documented by our favorite firewall vendor.
|
|||||||
|
|
||||||
Feel free to host your own version, or use [the one I host](https://firewallissues.axvig.com/).
|
Feel free to host your own version, or use [the one I host](https://firewallissues.axvig.com/).
|
||||||
|
|
||||||
|
Inspired by [Pixi888's](https://www.reddit.com/user/Pixi888/) creation [bugidsearch.com](https://bugidsearch.com/).
|
||||||
|
|
||||||
|
## Data updates ##
|
||||||
New versions are easily added using the process.html page
|
New versions are easily added using the process.html page
|
||||||
- Copy the issue table's HTML from the webpage using devtools.
|
- Copy the issue table's HTML from the webpage using devtools.
|
||||||
- Fill out the process.html page's fields and paste in the table HTML.
|
- Fill out the process.html page's fields and paste in the table HTML.
|
||||||
@@ -12,5 +15,8 @@ New versions are easily added using the process.html page
|
|||||||
|
|
||||||
There is intentionally no automated scaping, to avoid abuse of server resources. Also releases are not that frequent.
|
There is intentionally no automated scaping, to avoid abuse of server resources. Also releases are not that frequent.
|
||||||
|
|
||||||
|
## External references ##
|
||||||
|
|
||||||
Inspired by [Pixi888's](https://www.reddit.com/user/Pixi888/) creation [bugidsearch.com](https://bugidsearch.com/).
|
The `external_refs.json` file allows for links to be added to other websites that have information or discussion about certain issues.
|
||||||
|
|
||||||
|
I have vague ideas of something similar for CVEs.
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"id": "PAN-290235",
|
||||||
|
"url": "https://www.reddit.com/r/paloaltonetworks/comments/1qi7zoy/pan290235_dscd_and_low_quality_control/",
|
||||||
|
"display": "Reddit"
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
{
|
|
||||||
"reddit": {
|
|
||||||
"display": "Reddit",
|
|
||||||
"entries": [
|
|
||||||
{
|
|
||||||
"id": "PAN-290235",
|
|
||||||
"url": "https://www.reddit.com/r/paloaltonetworks/comments/1qi7zoy/pan290235_dscd_and_low_quality_control/"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"facebook": {
|
|
||||||
"display": "Facebook",
|
|
||||||
"entries": []
|
|
||||||
},
|
|
||||||
"twitter": {
|
|
||||||
"display": "Twitter",
|
|
||||||
"entries": []
|
|
||||||
},
|
|
||||||
"other_web": {
|
|
||||||
"display": "Other Web",
|
|
||||||
"entries": []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+18
-59
@@ -17,10 +17,10 @@ const issueFileDataCache = new Map();
|
|||||||
const issueFilePromiseCache = new Map();
|
const issueFilePromiseCache = new Map();
|
||||||
|
|
||||||
function loadSocialRefs() {
|
function loadSocialRefs() {
|
||||||
return fetch('data/social_refs.json')
|
return fetch('data/external_refs.json')
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`Failed to load data/social_refs.json (${response.status})`);
|
throw new Error(`Failed to load data/external_refs.json (${response.status})`);
|
||||||
}
|
}
|
||||||
return response.json();
|
return response.json();
|
||||||
})
|
})
|
||||||
@@ -28,7 +28,7 @@ function loadSocialRefs() {
|
|||||||
socialRefsByIssueId = normalizeSocialRefs(data);
|
socialRefsByIssueId = normalizeSocialRefs(data);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.warn('Social refs unavailable:', error);
|
console.warn('External refs unavailable:', error);
|
||||||
socialRefsByIssueId = new Map();
|
socialRefsByIssueId = new Map();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -477,73 +477,32 @@ function getSocialRefsForIssue(issueId) {
|
|||||||
|
|
||||||
function normalizeSocialRefs(data) {
|
function normalizeSocialRefs(data) {
|
||||||
const map = new Map();
|
const map = new Map();
|
||||||
if (!data || typeof data !== 'object') {
|
if (!Array.isArray(data)) {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.keys(data).forEach(sourceKey => {
|
data.forEach(entry => {
|
||||||
const sourceValue = data[sourceKey];
|
if (!entry || typeof entry !== 'object') {
|
||||||
const entries = getSourceEntries(sourceValue);
|
return;
|
||||||
const label = getSourceDisplayLabel(sourceKey, sourceValue);
|
}
|
||||||
|
|
||||||
entries.forEach(entry => {
|
const id = String(entry.id || '').trim().toUpperCase();
|
||||||
if (!entry || typeof entry !== 'object') {
|
const url = String(entry.url || '').trim();
|
||||||
return;
|
const label = String(entry.display || '').trim() || 'Link';
|
||||||
}
|
if (!id || !url) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const id = String(entry.id || '').trim().toUpperCase();
|
if (!map.has(id)) {
|
||||||
const url = String(entry.url || '').trim();
|
map.set(id, []);
|
||||||
if (!id || !url) {
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!map.has(id)) {
|
map.get(id).push({ label, url });
|
||||||
map.set(id, []);
|
|
||||||
}
|
|
||||||
|
|
||||||
map.get(id).push({ label, url });
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSourceEntries(sourceValue) {
|
|
||||||
if (Array.isArray(sourceValue)) {
|
|
||||||
return sourceValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sourceValue && typeof sourceValue === 'object' && Array.isArray(sourceValue.entries)) {
|
|
||||||
return sourceValue.entries;
|
|
||||||
}
|
|
||||||
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
function getSourceDisplayLabel(sourceKey, sourceValue) {
|
|
||||||
if (sourceValue && typeof sourceValue === 'object' && !Array.isArray(sourceValue)) {
|
|
||||||
const display = String(sourceValue.display || '').trim();
|
|
||||||
if (display) {
|
|
||||||
return display;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return sourceLabelFromKey(sourceKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
function sourceLabelFromKey(sourceKey) {
|
|
||||||
const key = String(sourceKey || '').trim().toLowerCase();
|
|
||||||
if (!key) {
|
|
||||||
return 'Link';
|
|
||||||
}
|
|
||||||
|
|
||||||
return key
|
|
||||||
.split(/[_\-\s]+/)
|
|
||||||
.filter(Boolean)
|
|
||||||
.map(part => part.charAt(0).toUpperCase() + part.slice(1))
|
|
||||||
.join(' ');
|
|
||||||
}
|
|
||||||
|
|
||||||
function markdownSummaryToHtml(summaryText, caveatText) {
|
function markdownSummaryToHtml(summaryText, caveatText) {
|
||||||
const input = String(summaryText || '').trim();
|
const input = String(summaryText || '').trim();
|
||||||
const caveat = String(caveatText || '').trim();
|
const caveat = String(caveatText || '').trim();
|
||||||
|
|||||||
Reference in New Issue
Block a user