core: Move SandboxType from avm1 to sandbox module
This commit is contained in:
parent
f1da1457eb
commit
6053fc586d
|
@ -7,6 +7,7 @@ use crate::avm1::runtime::Avm1;
|
||||||
use crate::avm1::{ScriptObject, TObject, Value};
|
use crate::avm1::{ScriptObject, TObject, Value};
|
||||||
use crate::avm1_stub;
|
use crate::avm1_stub;
|
||||||
use crate::context::{GcContext, UpdateContext};
|
use crate::context::{GcContext, UpdateContext};
|
||||||
|
use crate::sandbox::SandboxType;
|
||||||
use bitflags::bitflags;
|
use bitflags::bitflags;
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
|
|
||||||
|
@ -39,26 +40,6 @@ impl fmt::Display for CpuArchitecture {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Available type of sandbox for a given SWF
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub enum SandboxType {
|
|
||||||
Remote,
|
|
||||||
LocalWithFile,
|
|
||||||
LocalWithNetwork,
|
|
||||||
LocalTrusted,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Display for SandboxType {
|
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
||||||
fmt.write_str(match self {
|
|
||||||
SandboxType::Remote => "remote",
|
|
||||||
SandboxType::LocalWithFile => "localWithFile",
|
|
||||||
SandboxType::LocalWithNetwork => "localWithNetwork",
|
|
||||||
SandboxType::LocalTrusted => "localTrusted",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The available host operating systems
|
/// The available host operating systems
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub enum OperatingSystem {
|
pub enum OperatingSystem {
|
||||||
|
|
|
@ -5,6 +5,7 @@ use crate::avm1::property_decl::{define_properties_on, Declaration};
|
||||||
use crate::avm1::{ScriptObject, Value};
|
use crate::avm1::{ScriptObject, Value};
|
||||||
use crate::avm1_stub;
|
use crate::avm1_stub;
|
||||||
use crate::context::GcContext;
|
use crate::context::GcContext;
|
||||||
|
use crate::sandbox::SandboxType;
|
||||||
use crate::string::AvmString;
|
use crate::string::AvmString;
|
||||||
|
|
||||||
const OBJECT_DECLS: &[Declaration] = declare_properties! {
|
const OBJECT_DECLS: &[Declaration] = declare_properties! {
|
||||||
|
@ -60,7 +61,12 @@ fn get_sandbox_type<'gc>(
|
||||||
) -> Result<Value<'gc>, Error<'gc>> {
|
) -> Result<Value<'gc>, Error<'gc>> {
|
||||||
Ok(AvmString::new_utf8(
|
Ok(AvmString::new_utf8(
|
||||||
activation.context.gc_context,
|
activation.context.gc_context,
|
||||||
activation.context.system.sandbox_type.to_string(),
|
match activation.context.system.sandbox_type {
|
||||||
|
SandboxType::Remote => "remote",
|
||||||
|
SandboxType::LocalWithFile => "localWithFile",
|
||||||
|
SandboxType::LocalWithNetwork => "localWithNetwork",
|
||||||
|
SandboxType::LocalTrusted => "localTrusted",
|
||||||
|
},
|
||||||
)
|
)
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ use crate::avm2::object::Object;
|
||||||
use crate::avm2::value::Value;
|
use crate::avm2::value::Value;
|
||||||
use crate::avm2::Error;
|
use crate::avm2::Error;
|
||||||
use crate::avm2_stub_method;
|
use crate::avm2_stub_method;
|
||||||
|
use crate::sandbox::SandboxType;
|
||||||
use crate::string::AvmString;
|
use crate::string::AvmString;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
@ -38,7 +39,12 @@ pub fn get_sandbox_type<'gc>(
|
||||||
_this: Object<'gc>,
|
_this: Object<'gc>,
|
||||||
_args: &[Value<'gc>],
|
_args: &[Value<'gc>],
|
||||||
) -> Result<Value<'gc>, Error<'gc>> {
|
) -> Result<Value<'gc>, Error<'gc>> {
|
||||||
let sandbox_type = activation.context.system.sandbox_type.to_string();
|
let sandbox_type = match activation.context.system.sandbox_type {
|
||||||
|
SandboxType::Remote => "remote",
|
||||||
|
SandboxType::LocalWithFile => "localWithFile",
|
||||||
|
SandboxType::LocalWithNetwork => "localWithNetwork",
|
||||||
|
SandboxType::LocalTrusted => "localTrusted",
|
||||||
|
};
|
||||||
return Ok(AvmString::new_utf8(activation.context.gc_context, sandbox_type).into());
|
return Ok(AvmString::new_utf8(activation.context.gc_context, sandbox_type).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ mod net_connection;
|
||||||
pub mod pixel_bender;
|
pub mod pixel_bender;
|
||||||
mod player;
|
mod player;
|
||||||
mod prelude;
|
mod prelude;
|
||||||
|
pub mod sandbox;
|
||||||
pub mod socket;
|
pub mod socket;
|
||||||
mod streams;
|
mod streams;
|
||||||
pub mod string;
|
pub mod string;
|
||||||
|
@ -61,7 +62,6 @@ pub mod external;
|
||||||
pub mod i18n;
|
pub mod i18n;
|
||||||
pub mod stub;
|
pub mod stub;
|
||||||
|
|
||||||
pub use avm1::globals::system::SandboxType;
|
|
||||||
pub use context_menu::ContextMenuItem;
|
pub use context_menu::ContextMenuItem;
|
||||||
pub use events::PlayerEvent;
|
pub use events::PlayerEvent;
|
||||||
pub use font::DefaultFont;
|
pub use font::DefaultFont;
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use crate::avm1::globals::system::SandboxType;
|
|
||||||
use crate::avm1::Attribute;
|
use crate::avm1::Attribute;
|
||||||
use crate::avm1::Avm1;
|
use crate::avm1::Avm1;
|
||||||
use crate::avm1::Object;
|
use crate::avm1::Object;
|
||||||
|
@ -42,6 +41,7 @@ use crate::local_connection::LocalConnections;
|
||||||
use crate::locale::get_current_date_time;
|
use crate::locale::get_current_date_time;
|
||||||
use crate::net_connection::NetConnections;
|
use crate::net_connection::NetConnections;
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
use crate::sandbox::SandboxType;
|
||||||
use crate::socket::Sockets;
|
use crate::socket::Sockets;
|
||||||
use crate::streams::StreamManager;
|
use crate::streams::StreamManager;
|
||||||
use crate::string::{AvmString, AvmStringInterner};
|
use crate::string::{AvmString, AvmStringInterner};
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
//! Security Sandbox implementation, see
|
||||||
|
//! https://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7e3f.html
|
||||||
|
|
||||||
|
/// Type of sandbox that defines what a movie can access
|
||||||
|
/// and how movies interact with each other.
|
||||||
|
///
|
||||||
|
/// Note: sandbox type is defined *per SWF*.
|
||||||
|
pub enum SandboxType {
|
||||||
|
/// The movie originates from a remote URL.
|
||||||
|
///
|
||||||
|
/// In this case domain-based sandbox rules are used,
|
||||||
|
/// no filesystem access.
|
||||||
|
Remote,
|
||||||
|
|
||||||
|
/// The movie is a local movie with filesystem access.
|
||||||
|
///
|
||||||
|
/// This implies no network access.
|
||||||
|
LocalWithFile,
|
||||||
|
|
||||||
|
/// The movie is a local movie with network access.
|
||||||
|
///
|
||||||
|
/// This implies no filesystem access.
|
||||||
|
LocalWithNetwork,
|
||||||
|
|
||||||
|
/// The movie is a trusted local movie with access to both filesystem and network.
|
||||||
|
LocalTrusted,
|
||||||
|
}
|
|
@ -11,9 +11,9 @@ use ruffle_core::backend::storage::{MemoryStorageBackend, StorageBackend};
|
||||||
use ruffle_core::backend::ui::FontDefinition;
|
use ruffle_core::backend::ui::FontDefinition;
|
||||||
use ruffle_core::compatibility_rules::CompatibilityRules;
|
use ruffle_core::compatibility_rules::CompatibilityRules;
|
||||||
use ruffle_core::config::{Letterbox, NetworkingAccessMode};
|
use ruffle_core::config::{Letterbox, NetworkingAccessMode};
|
||||||
|
use ruffle_core::sandbox::SandboxType;
|
||||||
use ruffle_core::{
|
use ruffle_core::{
|
||||||
swf, Color, DefaultFont, Player, PlayerBuilder, PlayerRuntime, SandboxType, StageAlign,
|
swf, Color, DefaultFont, Player, PlayerBuilder, PlayerRuntime, StageAlign, StageScaleMode,
|
||||||
StageScaleMode,
|
|
||||||
};
|
};
|
||||||
use ruffle_render::backend::RenderBackend;
|
use ruffle_render::backend::RenderBackend;
|
||||||
use ruffle_render::quality::StageQuality;
|
use ruffle_render::quality::StageQuality;
|
||||||
|
|
Loading…
Reference in New Issue