fix: publish only explicitly public help and reject restricted artifacts
This commit is contained in:
parent
8aa8e2252b
commit
2276e20292
@ -39,3 +39,5 @@ restart the application or change its database/configuration. Use separate ident
|
|||||||
service, port, immutable releases, signing key, receipts and rollback.
|
service, port, immutable releases, signing key, receipts and rollback.
|
||||||
No Production activation or infrastructure modification without explicit approval.
|
No Production activation or infrastructure modification without explicit approval.
|
||||||
Do not modify unrelated web1 sites, especially catherinelynwood.com.
|
Do not modify unrelated web1 sites, especially catherinelynwood.com.
|
||||||
|
|
||||||
|
Help publication format 2 must declare audience public and explicit Visibility=public on every served article. Reject application/legacy/unclassified artifacts. Article visibility is maintained only in authoritative application Markdown, never a website exclusion list. See Docs/HelpVisibility.md. Pricing is an explicitly published snapshot, not an automatic DB feed; use the application PublicPricing exporter and review the correct environment before updating it.
|
||||||
|
|||||||
@ -28,7 +28,7 @@ or request-time timestamps are invented for the sitemap.
|
|||||||
public article URLs and linked assets are appropriate for the target release.
|
public article URLs and linked assets are appropriate for the target release.
|
||||||
Never publish a directory glob. Internal and unreleased content needs exclusion.
|
Never publish a directory glob. Internal and unreleased content needs exclusion.
|
||||||
2. Create a private approval JSON outside the checkout with `sourceCommit` (full
|
2. Create a private approval JSON outside the checkout with `sourceCommit` (full
|
||||||
current SHA), `channel` (`Development` or `Production`), `version` (unique content
|
current SHA), `channel` (`Development` or `Production`), `audience` (`public` or `application`), `version` (unique content
|
||||||
version) and `articles` (explicit array of existing public article URLs).
|
version) and `articles` (explicit array of existing public article URLs).
|
||||||
`Tools/PublicContent/production-approval.json` records the initial released URL
|
`Tools/PublicContent/production-approval.json` records the initial released URL
|
||||||
approval; it is historical input, not blanket approval for later changes.
|
approval; it is historical input, not blanket approval for later changes.
|
||||||
@ -63,10 +63,10 @@ For the installed Atlas website, the administrator uses
|
|||||||
`--store /opt/plotdirector-website-dev/shared/help`; Production uses
|
`--store /opt/plotdirector-website-dev/shared/help`; Production uses
|
||||||
`/srv/plotdirector-website/shared/help` and **must use `--channel Production`**.
|
`/srv/plotdirector-website/shared/help` and **must use `--channel Production`**.
|
||||||
Both channels are usable in Development, but explicitly choose the approved channel.
|
Both channels are usable in Development, but explicitly choose the approved channel.
|
||||||
For application help, consume the **same artifact and approved digest** into
|
For application help, consume the **application-audience artifact and its approved digest** into
|
||||||
`/opt/plotdirector-dev/shared/help` (Development) or `/srv/plotdirector/shared/help`
|
`/opt/plotdirector-dev/shared/help` (Development) or `/srv/plotdirector/shared/help`
|
||||||
(Production), using the application's `HelpContent__Path` to select its own `current`.
|
(Production), using the application's `HelpContent__Path` to select its own `current`.
|
||||||
These are separate immutable copies of one publication, not separately edited sources.
|
These are immutable public/application projections of one authoritative source, not separately edited documentation.
|
||||||
Neither deployment operates the other's store. Publish/rollback each pointer explicitly;
|
Neither deployment operates the other's store. Publish/rollback each pointer explicitly;
|
||||||
both services reload their own approved content without a restart.
|
both services reload their own approved content without a restart.
|
||||||
|
|
||||||
@ -100,3 +100,21 @@ checksums in `Content/brand-manifest.json`. Website owns public brand developmen
|
|||||||
`Tools/brand_package.py` publishes/consumes an explicitly versioned CSS/asset snapshot
|
`Tools/brand_package.py` publishes/consumes an explicitly versioned CSS/asset snapshot
|
||||||
for the application's authentication shell. The application pins a reviewed version;
|
for the application's authentication shell. The application pins a reviewed version;
|
||||||
independent deployments need not share a live filesystem or update simultaneously.
|
independent deployments need not share a live filesystem or update simultaneously.
|
||||||
|
|
||||||
|
## Visibility and pricing correction
|
||||||
|
|
||||||
|
See HelpVisibility.md. Publications now use format 2 and an explicit audience in
|
||||||
|
addition to the environment channel. Generate a `public` projection for the website
|
||||||
|
and an `application` projection for the application from the same source commit.
|
||||||
|
The latter retains administrator documentation, guarded by the application's existing
|
||||||
|
AdminOnly policy. Use `--audience application` only for the application content store;
|
||||||
|
the public consumer rejects that audience. A URL approval never overrides visibility.
|
||||||
|
|
||||||
|
Public pricing is **not automatically synchronised**. The current snapshot was checked
|
||||||
|
against Production's rendered plans; it is not a live database feed. The application
|
||||||
|
`Tools/PublicPricing` exporter now provides a reproducible read-only export of
|
||||||
|
`dbo.SubscriptionLevel_ListActive`, restricted to public plan fields and checkout IDs.
|
||||||
|
An authorised operator exports from the intended database, then a website developer
|
||||||
|
reviews and publishes the snapshot/provenance through the website's independent
|
||||||
|
release process. A database plan change therefore requires an explicit pricing
|
||||||
|
publication. Development limits must not be substituted for Production facts.
|
||||||
|
|||||||
36
Docs/HelpVisibility.md
Normal file
36
Docs/HelpVisibility.md
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# Explicit help visibility correction
|
||||||
|
|
||||||
|
The authoritative Markdown front matter declares `visibility: public`,
|
||||||
|
`administrator` or `internal`. All 409 articles were reviewed: 367 are public and
|
||||||
|
42 are administrator-only. The separate Help Authoring Guidelines document is
|
||||||
|
internal. The three nonrestricted references to "admin/administration" describe
|
||||||
|
ordinary writing work, not administrator functionality.
|
||||||
|
|
||||||
|
Serving code contains no category/path exclusion list. Public publication selects
|
||||||
|
only explicitly public articles. Unknown/missing classifications fail closed.
|
||||||
|
Format 2 publications declare both an environment channel and an audience:
|
||||||
|
|
||||||
|
- `public`: public articles and their referenced assets only.
|
||||||
|
- `application`: public plus administrator articles; no internal authoring material.
|
||||||
|
|
||||||
|
Both projections are generated from the same authoritative source commit. The
|
||||||
|
application uses its existing `AdminOnly` rule for all article lookups, categories,
|
||||||
|
search, recommendations and diagnostics. Cached source records are filtered for
|
||||||
|
each request, preventing a previous administrator request from leaking to others.
|
||||||
|
The website never authorizes administrator content, regardless of app cookies.
|
||||||
|
Its consumer rejects application/legacy/unclassified artifacts, and its reader
|
||||||
|
independently enforces public audience and visibility. Navigation, search, related
|
||||||
|
links, JSON-LD and sitemap use that same filtered content. Legacy/direct restricted
|
||||||
|
URLs return 404; no redirects to public copies are created.
|
||||||
|
|
||||||
|
The 42 articles and their sole category are intentionally withdrawn from the
|
||||||
|
public URL contract. The corrected website has 406 indexed URLs and 484 main
|
||||||
|
public routes. `Tests/restricted-help-routes.json` is generated audit/test evidence,
|
||||||
|
not a runtime exclusion list.
|
||||||
|
|
||||||
|
Publish using the application's Tools/PublicContent command and an approval with
|
||||||
|
`audience: public` or `application`. Select matching `--audience` when consuming;
|
||||||
|
website defaults to public, while the application requires `--audience application`.
|
||||||
|
The Production channel still requires explicit Production-compatible approval.
|
||||||
|
Do not roll back to legacy unclassified publications or pre-correction application
|
||||||
|
code: these are not safe public-help rollback targets.
|
||||||
@ -170,7 +170,7 @@ public sealed class HelpController(IHelpService help, IHelpMarkdownRenderer mark
|
|||||||
{
|
{
|
||||||
var article = help.GetByContextKey(WebUtility.UrlDecode(key));
|
var article = help.GetByContextKey(WebUtility.UrlDecode(key));
|
||||||
return article is null
|
return article is null
|
||||||
? View("ArticleNotFound", key)
|
? NotFound()
|
||||||
: RedirectPermanent(article.Url);
|
: RedirectPermanent(article.Url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
namespace PlotDirector.Website.Controllers;
|
namespace PlotDirector.Website.Controllers;
|
||||||
public sealed class HelpImageController(IWebHostEnvironment environment,IConfiguration configuration):Controller
|
public sealed class HelpImageController(IWebHostEnvironment environment,IConfiguration configuration,PlotDirector.Website.Services.IHelpService help):Controller
|
||||||
{
|
{
|
||||||
[HttpGet("/HelpDrawer/Image")]
|
[HttpGet("/HelpDrawer/Image")]
|
||||||
public IActionResult Image(string file)
|
public IActionResult Image(string file)
|
||||||
{
|
{
|
||||||
|
_ = help.GetAllArticles(); // Validate the public publication before serving any packaged asset.
|
||||||
if(string.IsNullOrWhiteSpace(file))return NotFound();
|
if(string.IsNullOrWhiteSpace(file))return NotFound();
|
||||||
var root=Path.GetFullPath(Path.Combine(configuration["HelpContent:Path"]??Path.Combine(environment.ContentRootPath,"Help/published"),"assets"));
|
var root=Path.GetFullPath(Path.Combine(configuration["HelpContent:Path"]??Path.Combine(environment.ContentRootPath,"Help/published"),"assets"));
|
||||||
var path=Path.GetFullPath(Path.Combine(root,file));
|
var path=Path.GetFullPath(Path.Combine(root,file));
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
|||||||
|
|
||||||
@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"format": 1,
|
"format": 2,
|
||||||
"sourceCommit": "3b391ca876f225aa3a29d0dce8d872a2d69df996",
|
"audience": "public",
|
||||||
|
"sourceCommit": "4232d0436e652d2cfa2b418e34dda42d5aeef29b",
|
||||||
"channel": "Production",
|
"channel": "Production",
|
||||||
"version": "2026.11.27-baseline",
|
"version": "2026.11.27-help-visibility-v2",
|
||||||
"files": {
|
"files": {
|
||||||
"articles.json": "3b9d8c915f5ed9f10dc5c862ff5431a97254f8fa41620032bf9d51c9539f14df",
|
"articles.json": "c2e9a8f77ab36abf10a9c8d613fc39e5fd8821f965d262ff55e8557934dcf6ed"
|
||||||
"assets/.gitkeep": "01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2,6 +2,7 @@ namespace PlotDirector.Website.Models;
|
|||||||
|
|
||||||
public sealed class HelpArticle
|
public sealed class HelpArticle
|
||||||
{
|
{
|
||||||
|
public string Visibility { get; set; } = "internal";
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
public string Category { get; set; } = string.Empty;
|
public string Category { get; set; } = string.Empty;
|
||||||
public string CategorySlug { get; set; } = string.Empty;
|
public string CategorySlug { get; set; } = string.Empty;
|
||||||
|
|||||||
@ -37,10 +37,13 @@ public sealed class HelpService(IWebHostEnvironment environment, IConfiguration
|
|||||||
{
|
{
|
||||||
if(cachedArticles is null || identity != packageIdentity)
|
if(cachedArticles is null || identity != packageIdentity)
|
||||||
{
|
{
|
||||||
|
using var manifest = System.Text.Json.JsonDocument.Parse(identity);
|
||||||
|
if (manifest.RootElement.GetProperty("format").GetInt32() != 2 || manifest.RootElement.GetProperty("audience").GetString() != "public")
|
||||||
|
throw new InvalidDataException("A public visibility-classified help publication is required.");
|
||||||
cachedArticles = System.Text.Json.JsonSerializer.Deserialize<List<HelpArticle>>(File.ReadAllText(package))!;
|
cachedArticles = System.Text.Json.JsonSerializer.Deserialize<List<HelpArticle>>(File.ReadAllText(package))!;
|
||||||
packageIdentity = identity;
|
packageIdentity = identity;
|
||||||
}
|
}
|
||||||
return cachedArticles;
|
return cachedArticles.Where(a => a.Visibility == "public").ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,6 @@
|
|||||||
"https://plotdirector.com/help/story-dynamics",
|
"https://plotdirector.com/help/story-dynamics",
|
||||||
"https://plotdirector.com/help/story-health",
|
"https://plotdirector.com/help/story-health",
|
||||||
"https://plotdirector.com/help/story-intelligence",
|
"https://plotdirector.com/help/story-intelligence",
|
||||||
"https://plotdirector.com/help/story-intelligence-admin",
|
|
||||||
"https://plotdirector.com/help/timeline",
|
"https://plotdirector.com/help/timeline",
|
||||||
"https://plotdirector.com/help/warnings",
|
"https://plotdirector.com/help/warnings",
|
||||||
"https://plotdirector.com/help/word-companion",
|
"https://plotdirector.com/help/word-companion",
|
||||||
@ -349,48 +348,6 @@
|
|||||||
"https://plotdirector.com/help/story-intelligence/story-intelligence-scene-metrics",
|
"https://plotdirector.com/help/story-intelligence/story-intelligence-scene-metrics",
|
||||||
"https://plotdirector.com/help/story-intelligence/story-intelligence-workflow",
|
"https://plotdirector.com/help/story-intelligence/story-intelligence-workflow",
|
||||||
"https://plotdirector.com/help/story-intelligence/story-location-baseline",
|
"https://plotdirector.com/help/story-intelligence/story-location-baseline",
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/admin-story-intelligence-import-preview",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/analyse-an-existing-chapter",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/analysis-book-context",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/analysis-chapter-context",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/analysis-chapter-number",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/analysis-configuration-status",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/analysis-project-context",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/analysis-prompt-availability",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/analysis-run-metadata",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/analysis-scene-context",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/analysis-scene-number",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/analysis-source-label",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/chapter-analysis-pre-flight",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/chapter-analysis-result",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/chapter-structure-test-model",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/chapter-test-source-text",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/chapter-text-upload",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/combined-chapter-analysis-test",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/confirming-an-admin-scene-import",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/development-data-reset",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/full-chapter-analysis-test",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/illustration-admin-notes",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/illustration-category-filter",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/illustration-generation-prompt",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/illustration-generation-queue",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/illustration-library-search",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/illustration-metadata",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/illustration-specification",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/illustration-status-filter",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/inspecting-a-story-intelligence-run",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/parsed-analysis-output",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/raw-analysis-response",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/reviewing-a-library-illustration",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/saved-story-intelligence-runs",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/scene-analysis-results",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/scene-intelligence-test-model",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/scene-test-context-output",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/scene-test-source-text",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/selected-chapter-source",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/story-intelligence-diagnostics",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/story-intelligence-illustration-library",
|
|
||||||
"https://plotdirector.com/help/story-intelligence-admin/story-intelligence-scene-dry-run",
|
|
||||||
"https://plotdirector.com/help/timeline/asset-events",
|
"https://plotdirector.com/help/timeline/asset-events",
|
||||||
"https://plotdirector.com/help/timeline/character-appearances",
|
"https://plotdirector.com/help/timeline/character-appearances",
|
||||||
"https://plotdirector.com/help/timeline/filters-and-focus",
|
"https://plotdirector.com/help/timeline/filters-and-focus",
|
||||||
@ -547,5 +504,53 @@
|
|||||||
"/sitemap.xml",
|
"/sitemap.xml",
|
||||||
"/llms.txt",
|
"/llms.txt",
|
||||||
"/llms-full.txt"
|
"/llms-full.txt"
|
||||||
]
|
],
|
||||||
|
"visibilityCorrection": {
|
||||||
|
"source": "authoritative visibility metadata",
|
||||||
|
"withdrawnRestrictedUrls": [
|
||||||
|
"/help/story-intelligence-admin",
|
||||||
|
"/help/story-intelligence-admin/admin-story-intelligence-import-preview",
|
||||||
|
"/help/story-intelligence-admin/analyse-an-existing-chapter",
|
||||||
|
"/help/story-intelligence-admin/analysis-book-context",
|
||||||
|
"/help/story-intelligence-admin/analysis-chapter-context",
|
||||||
|
"/help/story-intelligence-admin/analysis-chapter-number",
|
||||||
|
"/help/story-intelligence-admin/analysis-configuration-status",
|
||||||
|
"/help/story-intelligence-admin/analysis-project-context",
|
||||||
|
"/help/story-intelligence-admin/analysis-prompt-availability",
|
||||||
|
"/help/story-intelligence-admin/analysis-run-metadata",
|
||||||
|
"/help/story-intelligence-admin/analysis-scene-context",
|
||||||
|
"/help/story-intelligence-admin/analysis-scene-number",
|
||||||
|
"/help/story-intelligence-admin/analysis-source-label",
|
||||||
|
"/help/story-intelligence-admin/chapter-analysis-pre-flight",
|
||||||
|
"/help/story-intelligence-admin/chapter-analysis-result",
|
||||||
|
"/help/story-intelligence-admin/chapter-structure-test-model",
|
||||||
|
"/help/story-intelligence-admin/chapter-test-source-text",
|
||||||
|
"/help/story-intelligence-admin/chapter-text-upload",
|
||||||
|
"/help/story-intelligence-admin/combined-chapter-analysis-test",
|
||||||
|
"/help/story-intelligence-admin/confirming-an-admin-scene-import",
|
||||||
|
"/help/story-intelligence-admin/development-data-reset",
|
||||||
|
"/help/story-intelligence-admin/full-chapter-analysis-test",
|
||||||
|
"/help/story-intelligence-admin/illustration-admin-notes",
|
||||||
|
"/help/story-intelligence-admin/illustration-category-filter",
|
||||||
|
"/help/story-intelligence-admin/illustration-generation-prompt",
|
||||||
|
"/help/story-intelligence-admin/illustration-generation-queue",
|
||||||
|
"/help/story-intelligence-admin/illustration-library-search",
|
||||||
|
"/help/story-intelligence-admin/illustration-metadata",
|
||||||
|
"/help/story-intelligence-admin/illustration-specification",
|
||||||
|
"/help/story-intelligence-admin/illustration-status-filter",
|
||||||
|
"/help/story-intelligence-admin/inspecting-a-story-intelligence-run",
|
||||||
|
"/help/story-intelligence-admin/parsed-analysis-output",
|
||||||
|
"/help/story-intelligence-admin/raw-analysis-response",
|
||||||
|
"/help/story-intelligence-admin/reviewing-a-library-illustration",
|
||||||
|
"/help/story-intelligence-admin/saved-story-intelligence-runs",
|
||||||
|
"/help/story-intelligence-admin/scene-analysis-results",
|
||||||
|
"/help/story-intelligence-admin/scene-intelligence-test-model",
|
||||||
|
"/help/story-intelligence-admin/scene-test-context-output",
|
||||||
|
"/help/story-intelligence-admin/scene-test-source-text",
|
||||||
|
"/help/story-intelligence-admin/selected-chapter-source",
|
||||||
|
"/help/story-intelligence-admin/story-intelligence-diagnostics",
|
||||||
|
"/help/story-intelligence-admin/story-intelligence-illustration-library",
|
||||||
|
"/help/story-intelligence-admin/story-intelligence-scene-dry-run"
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
301
Tests/restricted-help-routes.json
Normal file
301
Tests/restricted-help-routes.json
Normal file
@ -0,0 +1,301 @@
|
|||||||
|
{
|
||||||
|
"articles": [
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/chapter-analysis-result",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.chapterResult",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/ChapterResult.md",
|
||||||
|
"Title": "Chapter Analysis Result"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/combined-chapter-analysis-test",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.chapterTest",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/ChapterTest.md",
|
||||||
|
"Title": "Combined Chapter Analysis Test"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/confirming-an-admin-scene-import",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.commit",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Commit.md",
|
||||||
|
"Title": "Confirming an Admin Scene Import"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/analysis-configuration-status",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.configuration",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Configuration.md",
|
||||||
|
"Title": "Analysis Configuration Status"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/story-intelligence-diagnostics",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.diagnostics",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Diagnostics.md",
|
||||||
|
"Title": "Story Intelligence Diagnostics"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/analyse-an-existing-chapter",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.existingChapter",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/ExistingChapter.md",
|
||||||
|
"Title": "Analyse an Existing Chapter"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/analysis-book-context",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.fields.book",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Fields/Book.md",
|
||||||
|
"Title": "Analysis Book Context"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/analysis-chapter-context",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.fields.chapter",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Fields/Chapter.md",
|
||||||
|
"Title": "Analysis Chapter Context"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/chapter-structure-test-model",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.fields.chapterModel",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Fields/ChapterModel.md",
|
||||||
|
"Title": "Chapter Structure Test Model"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/analysis-chapter-number",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.fields.chapterNumber",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Fields/ChapterNumber.md",
|
||||||
|
"Title": "Analysis Chapter Number"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/chapter-test-source-text",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.fields.chapterText",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Fields/ChapterText.md",
|
||||||
|
"Title": "Chapter Test Source Text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/illustration-category-filter",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.fields.illustrationCategory",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Fields/IllustrationCategory.md",
|
||||||
|
"Title": "Illustration Category Filter"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/illustration-metadata",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.fields.illustrationMetadata",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Fields/IllustrationMetadata.md",
|
||||||
|
"Title": "Illustration Metadata"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/illustration-admin-notes",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.fields.illustrationNotes",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Fields/IllustrationNotes.md",
|
||||||
|
"Title": "Illustration Admin Notes"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/illustration-generation-prompt",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.fields.illustrationPrompt",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Fields/IllustrationPrompt.md",
|
||||||
|
"Title": "Illustration Generation Prompt"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/illustration-library-search",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.fields.illustrationSearch",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Fields/IllustrationSearch.md",
|
||||||
|
"Title": "Illustration Library Search"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/illustration-specification",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.fields.illustrationSpecification",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Fields/IllustrationSpecification.md",
|
||||||
|
"Title": "Illustration Specification"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/illustration-status-filter",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.fields.illustrationStatus",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Fields/IllustrationStatus.md",
|
||||||
|
"Title": "Illustration Status Filter"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/parsed-analysis-output",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.fields.parsedOutput",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Fields/ParsedOutput.md",
|
||||||
|
"Title": "Parsed Analysis Output"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/analysis-project-context",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.fields.project",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Fields/Project.md",
|
||||||
|
"Title": "Analysis Project Context"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/raw-analysis-response",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.fields.rawOutput",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Fields/RawOutput.md",
|
||||||
|
"Title": "Raw Analysis Response"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/analysis-scene-context",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.fields.scene",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Fields/Scene.md",
|
||||||
|
"Title": "Analysis Scene Context"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/scene-test-context-output",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.fields.sceneContext",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Fields/SceneContext.md",
|
||||||
|
"Title": "Scene Test Context Output"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/scene-intelligence-test-model",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.fields.sceneModel",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Fields/SceneModel.md",
|
||||||
|
"Title": "Scene Intelligence Test Model"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/analysis-scene-number",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.fields.sceneNumber",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Fields/SceneNumber.md",
|
||||||
|
"Title": "Analysis Scene Number"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/scene-test-source-text",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.fields.sceneText",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Fields/SceneText.md",
|
||||||
|
"Title": "Scene Test Source Text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/analysis-source-label",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.fields.sourceLabel",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Fields/SourceLabel.md",
|
||||||
|
"Title": "Analysis Source Label"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/chapter-text-upload",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.fields.upload",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Fields/Upload.md",
|
||||||
|
"Title": "Chapter Text Upload"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/full-chapter-analysis-test",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.fullChapterTest",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/FullChapterTest.md",
|
||||||
|
"Title": "Full Chapter Analysis Test"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/illustration-generation-queue",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.illustrationQueue",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/IllustrationQueue.md",
|
||||||
|
"Title": "Illustration Generation Queue"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/reviewing-a-library-illustration",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.illustrationReview",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/IllustrationReview.md",
|
||||||
|
"Title": "Reviewing a Library Illustration"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/story-intelligence-illustration-library",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.illustrations",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Illustrations.md",
|
||||||
|
"Title": "Story Intelligence Illustration Library"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/admin-story-intelligence-import-preview",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.importPreview",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/ImportPreview.md",
|
||||||
|
"Title": "Admin Story Intelligence Import Preview"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/analysis-run-metadata",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.metadata",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Metadata.md",
|
||||||
|
"Title": "Analysis Run Metadata"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/chapter-analysis-pre-flight",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.preflight",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Preflight.md",
|
||||||
|
"Title": "Chapter Analysis Pre-flight"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/analysis-prompt-availability",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.prompts",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Prompts.md",
|
||||||
|
"Title": "Analysis Prompt Availability"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/development-data-reset",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.reset",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Reset.md",
|
||||||
|
"Title": "Development Data Reset"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/inspecting-a-story-intelligence-run",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.runDetails",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/RunDetails.md",
|
||||||
|
"Title": "Inspecting a Story Intelligence Run"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/saved-story-intelligence-runs",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.runs",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Runs.md",
|
||||||
|
"Title": "Saved Story Intelligence Runs"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/scene-analysis-results",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.sceneResults",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/SceneResults.md",
|
||||||
|
"Title": "Scene Analysis Results"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/story-intelligence-scene-dry-run",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.sceneTest",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/SceneTest.md",
|
||||||
|
"Title": "Story Intelligence Scene Dry Run"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Url": "/help/story-intelligence-admin/selected-chapter-source",
|
||||||
|
"CategoryUrl": "/help/story-intelligence-admin",
|
||||||
|
"ContextKey": "storyIntelligence.admin.source",
|
||||||
|
"RelativePath": "StoryIntelligence/Admin/Source.md",
|
||||||
|
"Title": "Selected Chapter Source"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"categories": [
|
||||||
|
"/help/story-intelligence-admin"
|
||||||
|
]
|
||||||
|
}
|
||||||
31
Tests/test_help_publication.py
Normal file
31
Tests/test_help_publication.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import importlib.util,json,hashlib,tempfile,unittest
|
||||||
|
from pathlib import Path
|
||||||
|
spec=importlib.util.spec_from_file_location('consume_help',Path(__file__).resolve().parents[1]/'Tools/consume_help.py');module=importlib.util.module_from_spec(spec);spec.loader.exec_module(module)
|
||||||
|
class PublicationVisibilityTests(unittest.TestCase):
|
||||||
|
def setUp(self):self.tmp=tempfile.TemporaryDirectory();self.root=Path(self.tmp.name)
|
||||||
|
def tearDown(self):self.tmp.cleanup()
|
||||||
|
def package(self,visibility='public',audience='public',version=2):
|
||||||
|
source=self.root/'source';source.mkdir();data=[{'Title':'Fixture','Category':'Projects','CategorySlug':'projects','Slug':'fixture','Visibility':visibility}]
|
||||||
|
if visibility is None:del data[0]['Visibility']
|
||||||
|
(source/'articles.json').write_text(json.dumps(data));m={'format':version,'channel':'Development','audience':audience,'version':'test','files':{'articles.json':hashlib.sha256((source/'articles.json').read_bytes()).hexdigest()}};(source/'manifest.json').write_text(json.dumps(m));return source,hashlib.sha256((source/'manifest.json').read_bytes()).hexdigest()
|
||||||
|
def test_public_accepted(self):
|
||||||
|
source,digest=self.package();module.consume(source,self.root/'store','Development',digest);self.assertTrue((self.root/'store/current/articles.json').exists())
|
||||||
|
def test_administrator_rejected_even_in_public_category(self):
|
||||||
|
source,digest=self.package('administrator')
|
||||||
|
with self.assertRaises(ValueError):module.consume(source,self.root/'store','Development',digest)
|
||||||
|
self.assertFalse((self.root/'store/current').exists())
|
||||||
|
def test_unclassified_rejected(self):
|
||||||
|
source,digest=self.package(None)
|
||||||
|
with self.assertRaises(ValueError):module.consume(source,self.root/'store','Development',digest)
|
||||||
|
def test_internal_rejected(self):
|
||||||
|
source,digest=self.package('internal')
|
||||||
|
with self.assertRaises(ValueError):module.consume(source,self.root/'store','Development',digest)
|
||||||
|
def test_application_audience_cannot_enter_public_store(self):
|
||||||
|
source,digest=self.package('administrator','application')
|
||||||
|
with self.assertRaises(ValueError):module.consume(source,self.root/'store','Development',digest)
|
||||||
|
def test_administrator_retained_in_explicit_application_publication(self):
|
||||||
|
source,digest=self.package('administrator','application');module.consume(source,self.root/'store','Development',digest,'application');self.assertEqual(json.loads((self.root/'store/current/articles.json').read_text())[0]['Visibility'],'administrator')
|
||||||
|
def test_legacy_unclassified_format_refused(self):
|
||||||
|
source,digest=self.package(version=1)
|
||||||
|
with self.assertRaises(ValueError):module.consume(source,self.root/'store','Development',digest)
|
||||||
|
if __name__=='__main__':unittest.main()
|
||||||
@ -76,7 +76,25 @@ def run(origin,production=False):
|
|||||||
articles=json.loads((root/'PlotDirector.Website/Help/published/articles.json').read_text())
|
articles=json.loads((root/'PlotDirector.Website/Help/published/articles.json').read_text())
|
||||||
sample=articles[0];status,fragment,headers=fetch('/HelpDrawer/Article?key='+urllib.parse.quote(sample['ContextKey']))
|
sample=articles[0];status,fragment,headers=fetch('/HelpDrawer/Article?key='+urllib.parse.quote(sample['ContextKey']))
|
||||||
if status!=200 or sample['Title'] not in fragment.decode() or 'noindex' not in headers.get('X-Robots-Tag',''):errors.append('published legacy help fragment differs')
|
if status!=200 or sample['Title'] not in fragment.decode() or 'noindex' not in headers.get('X-Robots-Tag',''):errors.append('published legacy help fragment differs')
|
||||||
report={'origin':origin,'productionPolicy':production,'baselineUrls':len(public),'renderedPages':len(pages),'internalPaths':len(links),'assets':len(assets),'errors':errors,'passed':not errors}
|
restricted=json.loads((root/'Tests/restricted-help-routes.json').read_text())
|
||||||
|
restricted_paths=set(restricted['categories'])|{a['Url'] for a in restricted['articles']}
|
||||||
|
for path in restricted_paths:
|
||||||
|
try:fetch(path);errors.append(path+': restricted anonymous access was not denied')
|
||||||
|
except urllib.error.HTTPError as e:
|
||||||
|
if e.code!=404:errors.append(path+': restricted route must return 404')
|
||||||
|
for article in restricted['articles']:
|
||||||
|
for path in ['/Help/Article/'+urllib.parse.quote(article['ContextKey']),'/HelpDrawer/Article?key='+urllib.parse.quote(article['ContextKey'])]:
|
||||||
|
try:fetch(path);errors.append(path+': restricted alias was not denied')
|
||||||
|
except urllib.error.HTTPError as e:
|
||||||
|
if e.code!=404:errors.append(path+': restricted alias must return 404')
|
||||||
|
_,body,_=fetch('/help?q='+urllib.parse.quote(article['Title']));search=Page();search.feed(body.decode())
|
||||||
|
if any(urllib.parse.urlsplit(u).path in restricted_paths for u in search.links):errors.append('Restricted article in help search')
|
||||||
|
for path in ['/help','/sitemap.xml','/llms.txt','/llms-full.txt']:
|
||||||
|
_,body,_=fetch(path);body=body.decode()
|
||||||
|
if 'story-intelligence-admin' in body.lower() or 'storyIntelligence.admin.' in body:errors.append(path+': restricted navigation/index entry')
|
||||||
|
for path,page in pages.items():
|
||||||
|
if any(urllib.parse.urlsplit(u).path in restricted_paths for u in page.links):errors.append(path+': restricted related/navigation link')
|
||||||
|
report={'origin':origin,'productionPolicy':production,'baselineUrls':len(public),'renderedPages':len(pages),'internalPaths':len(links),'assets':len(assets),'restrictedArticlesChecked':len(restricted['articles']),'errors':errors,'passed':not errors}
|
||||||
print(json.dumps(report,indent=2));return bool(errors)
|
print(json.dumps(report,indent=2));return bool(errors)
|
||||||
if __name__=='__main__':
|
if __name__=='__main__':
|
||||||
p=argparse.ArgumentParser();p.add_argument('--origin',required=True);p.add_argument('--production',action='store_true');a=p.parse_args();sys.exit(run(a.origin.rstrip('/'),a.production))
|
p=argparse.ArgumentParser();p.add_argument('--origin',required=True);p.add_argument('--production',action='store_true');a=p.parse_args();sys.exit(run(a.origin.rstrip('/'),a.production))
|
||||||
|
|||||||
@ -3,12 +3,12 @@
|
|||||||
import argparse,hashlib,json,os,shutil,tempfile
|
import argparse,hashlib,json,os,shutil,tempfile
|
||||||
from pathlib import Path,PurePosixPath
|
from pathlib import Path,PurePosixPath
|
||||||
|
|
||||||
def consume(source,store,channel,expected):
|
def consume(source,store,channel,expected,audience="public"):
|
||||||
source,store=Path(source).resolve(),Path(store).resolve()
|
source,store=Path(source).resolve(),Path(store).resolve()
|
||||||
manifest=(source/'manifest.json').read_bytes()
|
manifest=(source/'manifest.json').read_bytes()
|
||||||
if hashlib.sha256(manifest).hexdigest()!=expected:raise ValueError('Approved manifest digest differs')
|
if hashlib.sha256(manifest).hexdigest()!=expected:raise ValueError('Approved manifest digest differs')
|
||||||
m=json.loads(manifest)
|
m=json.loads(manifest)
|
||||||
if m['format']!=1 or m['channel']!=channel:raise ValueError('Wrong content publication channel')
|
if m['format']!=2 or m['channel']!=channel or m.get('audience')!=audience:raise ValueError('Wrong publication format, channel or audience')
|
||||||
if not m['files'] or 'articles.json' not in m['files']:raise ValueError('Missing article inventory')
|
if not m['files'] or 'articles.json' not in m['files']:raise ValueError('Missing article inventory')
|
||||||
store.mkdir(parents=True,exist_ok=True)
|
store.mkdir(parents=True,exist_ok=True)
|
||||||
version=store/expected
|
version=store/expected
|
||||||
@ -25,7 +25,8 @@ def consume(source,store,channel,expected):
|
|||||||
out=temp/name;out.parent.mkdir(parents=True,exist_ok=True);out.write_bytes(data)
|
out=temp/name;out.parent.mkdir(parents=True,exist_ok=True);out.write_bytes(data)
|
||||||
articles=json.loads((temp/'articles.json').read_text())
|
articles=json.loads((temp/'articles.json').read_text())
|
||||||
urls=[a['CategorySlug']+'/'+a['Slug'] for a in articles]
|
urls=[a['CategorySlug']+'/'+a['Slug'] for a in articles]
|
||||||
if len(urls)!=len(set(urls)) or any(a['Category'].lower()=='internal' for a in articles):raise ValueError('Invalid public articles')
|
allowed={'public'} if audience=='public' else {'public','administrator'}
|
||||||
|
if len(urls)!=len(set(urls)) or any(a.get('Visibility') not in allowed for a in articles):raise ValueError('Restricted or unclassified article in publication')
|
||||||
(temp/'manifest.json').write_bytes(manifest)
|
(temp/'manifest.json').write_bytes(manifest)
|
||||||
for file in temp.rglob('*'):
|
for file in temp.rglob('*'):
|
||||||
file.chmod(0o755 if file.is_dir() else 0o444)
|
file.chmod(0o755 if file.is_dir() else 0o444)
|
||||||
@ -35,6 +36,6 @@ def consume(source,store,channel,expected):
|
|||||||
link=store/('.current-'+expected)
|
link=store/('.current-'+expected)
|
||||||
link.symlink_to(version)
|
link.symlink_to(version)
|
||||||
os.replace(link,store/'current')
|
os.replace(link,store/'current')
|
||||||
print(json.dumps({'channel':channel,'version':m['version'],'manifestSha256':expected,'articles':len(articles)}))
|
print(json.dumps({'channel':channel,'audience':audience,'version':m['version'],'manifestSha256':expected,'articles':len(articles)}))
|
||||||
if __name__=='__main__':
|
if __name__=='__main__':
|
||||||
p=argparse.ArgumentParser();p.add_argument('source');p.add_argument('--store',required=True);p.add_argument('--channel',choices=['Development','Production'],required=True);p.add_argument('--manifest-sha256',required=True);a=p.parse_args();consume(a.source,a.store,a.channel,a.manifest_sha256)
|
p=argparse.ArgumentParser();p.add_argument('source');p.add_argument('--store',required=True);p.add_argument('--channel',choices=['Development','Production'],required=True);p.add_argument('--manifest-sha256',required=True);p.add_argument('--audience',choices=['public','application'],default='public');a=p.parse_args();consume(a.source,a.store,a.channel,a.manifest_sha256,a.audience)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user